瀏覽代碼

快站

master
huangjiajun 2 月之前
父節點
當前提交
47b6906cf1
共有 22 個檔案被更改,包括 1051 行新增0 行删除
  1. +15
    -0
      db/offical/db_kuaizhan_short_url.go
  2. +15
    -0
      db/offical/db_kuaizhan_url.go
  3. +11
    -0
      db/offical/model/kuaizhan_short_url_money.go
  4. +7
    -0
      db/offical/model/kuaizhan_short_url_num_list.go
  5. +27
    -0
      db/offical/model/kuaizhan_short_url_record.go
  6. +9
    -0
      db/offical/model/kuaizhan_url.go
  7. +244
    -0
      e/code.go
  8. +72
    -0
      e/error.go
  9. +8
    -0
      e/set_cache.go
  10. +1
    -0
      go.mod
  11. +6
    -0
      go.sum
  12. +9
    -0
      kuaizhan/kuaizhan_test.go
  13. +84
    -0
      kuaizhan/short_url.go
  14. +21
    -0
      kuaizhan/url.go
  15. +279
    -0
      md/cfg_key.go
  16. +62
    -0
      md/file.go
  17. +67
    -0
      qiniuyun/api.go
  18. +16
    -0
      qiniuyun/bucket_create.go
  19. +18
    -0
      qiniuyun/bucket_delete.go
  20. +18
    -0
      qiniuyun/bucket_get_domain.go
  21. +20
    -0
      qiniuyun/init.go
  22. +42
    -0
      qiniuyun/req_img_upload.go

+ 15
- 0
db/offical/db_kuaizhan_short_url.go 查看文件

@@ -0,0 +1,15 @@
package offical

import (
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/db/offical/model"
"xorm.io/xorm"
)

func GetKuaizhanShortUrl(engine *xorm.Engine, uid interface{}) *model.KuaizhanShortUrlNumList {
var data model.KuaizhanShortUrlNumList
get, err := engine.Where("uid=?", uid).Get(&data)
if get == false || err != nil {
return nil
}
return &data
}

+ 15
- 0
db/offical/db_kuaizhan_url.go 查看文件

@@ -0,0 +1,15 @@
package offical

import (
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/db/offical/model"
"xorm.io/xorm"
)

func GetKuaizhanUrl(engine *xorm.Engine, uid interface{}) *model.KuaizhanUrl {
var data model.KuaizhanUrl
get, err := engine.Where("uid=?", uid).Get(&data)
if get == false || err != nil {
return nil
}
return &data
}

+ 11
- 0
db/offical/model/kuaizhan_short_url_money.go 查看文件

@@ -0,0 +1,11 @@
package model

type KuaizhanShortUrlMoney struct {
Id int `json:"id" xorm:"not null pk autoincr INT(11)"`
Money float64 `json:"money" xorm:"default 0.00 comment('金额') DOUBLE(11,2)"`
Num int `json:"num" xorm:"default 0 comment('短信条数') INT(11)"`
Hide int `json:"hide" xorm:"default 0 comment('0否 1是') INT(1)"`
Sort int `json:"sort" xorm:"default 0 comment('排序') INT(11)"`
UpdateTime int `json:"update_time" xorm:"default 0 comment('修改时间') INT(11)"`
Time int `json:"time" xorm:"default 0 comment('创建时间') INT(11)"`
}

+ 7
- 0
db/offical/model/kuaizhan_short_url_num_list.go 查看文件

@@ -0,0 +1,7 @@
package model

type KuaizhanShortUrlNumList struct {
Id int `json:"id" xorm:"not null pk autoincr INT(11)"`
Uid int `json:"uid" xorm:"default 0 comment('用户') INT(11)"`
Num int `json:"num" xorm:"default 0 comment('短信条数') INT(11)"`
}

+ 27
- 0
db/offical/model/kuaizhan_short_url_record.go 查看文件

@@ -0,0 +1,27 @@
package model

import (
"time"
)

type KuaizhanShortUrlRecord struct {
Id int `json:"id" xorm:"not null pk autoincr INT(11)"`
OrdId string `json:"ord_id" xorm:"not null default '' comment('订单id') VARCHAR(100)"`
Uid int `json:"uid" xorm:"not null default 0 comment('主用户id') INT(11)"`
Phone string `json:"phone" xorm:"not null default 0 comment('主账号-手机号码') VARCHAR(255)"`
Nickname string `json:"nickname" xorm:"not null default '' comment('主账号-昵称') VARCHAR(255)"`
Amount string `json:"amount" xorm:"not null default '0' comment('充值金额') VARCHAR(255)"`
CostPrice string `json:"cost_price" xorm:"not null default '0' comment('付费价格') VARCHAR(255)"`
Balance string `json:"balance" xorm:"not null default '0' comment('当前余额(充值完当前余额)') VARCHAR(255)"`
PayWay int `json:"pay_way" xorm:"not null default 1 comment('支付方式(1:支付宝 2:微信 3:余额)') TINYINT(1)"`
State int `json:"state" xorm:"not null default 0 comment('状态(0:待付款 1:已付款 2:付款失败)') TINYINT(2)"`
Memo string `json:"memo" xorm:"not null default '' comment('备注') VARCHAR(255)"`
CreateAt time.Time `json:"create_at" xorm:"not null default CURRENT_TIMESTAMP comment('创建时间') DATETIME"`
UpdateAt time.Time `json:"update_at" xorm:"default CURRENT_TIMESTAMP comment('更新时间') DATETIME"`
TradeNo string `json:"trade_no" xorm:"not null default '' comment('支付平台(支付宝/微信)订单号') VARCHAR(100)"`
Type int `json:"type" xorm:"default 0 comment('0收入 1支出') INT(1)"`
OrdType string `json:"ord_type" xorm:"comment('订单类型') VARCHAR(255)"`
SubUid int `json:"sub_uid" xorm:"default 0 INT(11)"`
Fee string `json:"fee" xorm:"VARCHAR(255)"`
Ext string `json:"ext" xorm:"TEXT"`
}

+ 9
- 0
db/offical/model/kuaizhan_url.go 查看文件

@@ -0,0 +1,9 @@
package model

import "time"

type KuaizhanUrl struct {
Id int `json:"id" xorm:"not null pk autoincr INT(11)"`
Uid int `json:"uid" xorm:"default 0 comment('用户') INT(11)"`
EndTime time.Time `json:"end_time" xorm:"not null default '' comment('') DATETIME"`
}

+ 244
- 0
e/code.go 查看文件

@@ -0,0 +1,244 @@
package e

const (
// 200 因为部分第三方接口不能返回错误头,因此在此定义部分错误
ERR_FILE_SAVE = 200001
// 400 系列
ERR_BAD_REQUEST = 400000
ERR_INVALID_ARGS = 400001
ERR_API_RESPONSE = 400002
ERR_NO_DATA = 400003
ERR_MOBILE_NIL = 400004
ERR_MOBILE_MATH = 400005
ERR_FILE_EXT = 400006
ERR_FILE_MAX_SIZE = 400007
ERR_SIGN = 400008
ERR_PASSWORD_MATH = 400009
ERR_PROVIDER_RESPONSE = 400010
ERR_AES_ENCODE = 400011
ERR_ADMIN_API = 400012
ERR_QINIUAPI_RESPONSE = 400013
ERR_URL_TURNCHAIN = 400014

// 401 未授权
ERR_UNAUTHORIZED = 401000
ERR_NOT_AUTH = 401001
ERR_SMS_AUTH = 401002
ERR_TOKEN_AUTH = 401003
ERR_TOKEN_FORMAT = 401004
ERR_TOKEN_GEN = 401005
// 403 禁止
ERR_FORBIDEN = 403000
ERR_PLATFORM = 403001
ERR_MOBILE_EXIST = 403002
ERR_USER_NO_EXIST = 403003
ERR_MOBILE_NO_EXIST = 403004
ERR_FORBIDEN_VALID = 403005
ERR_RELATE_ERR = 403006
ERR_REPEAT_RELATE = 403007
ERR_MOB_FORBIDEN = 403008
ERR_MOB_SMS_NO_AVA = 403009
ERR_USER_IS_REG = 403010
ERR_MASTER_ID = 403011
ERR_CASH_OUT_TIME = 403012
ERR_CASH_OUT_FEE = 403013
ERR_CASH_OUT_USER_NOT_FOUND = 403014
ERR_CASH_OUT_FAIL = 403015
ERR_CASH_OUT_TIMES = 403016
ERR_CASH_OUT_MINI = 403017
ERR_CASH_OUT_MUT = 403018
ERR_CASH_OUT_NOT_DECIMAL = 403019
ERR_CASH_OUT_NOT_DAY_AVA = 403020
ERR_USER_LEVEL_PAY_CHECK_TASK_NO_DONE = 403021
ERR_USER_LEVEL_PAY_CHECK_NO_CROSS = 403022
ERR_USER_LEVEL_ORD_EXP = 403023
ERR_IS_BIND_THIRDPARTY = 403024
ERR_USER_LEVEL_UPDATE_CHECK_TASK_NO_DONE = 403025
ERR_USER_LEVEL_UPDATE_CHECK_NOT_FOUND_ORDER = 403026
ERR_USER_LEVEL_UPDATE_REPEAT = 403027
ERR_USER_NO_ACTIVE = 403028
ERR_USER_IS_BAN = 403029
ERR_ALIPAY_SETTING = 403030
ERR_ALIPAY_ORDERTYPE = 403031
ERR_CLIPBOARD_UNSUP = 403032
ERR_SYSUNION_CONFIG = 403033
ERR_WECAHT_MINI = 403034
ERR_WECAHT_MINI_CACHE = 403035
ERR_WECAHT_MINI_DECODE = 403036
ERR_WECHAT_MINI_ACCESSTOKEN = 403037
ERR_CURRENT_VIP_LEVEL_AUDITING = 403038
ERR_LEVEL_RENEW_SHOULD_KEEP_CURRENT = 403039
ERR_LEVEL_UPGRADE_APPLY_AUDITTING = 403040
ERR_LEVEL_TASK_PAY_TYPE = 403041
ERR_BALANCE_NOT_ENOUGH = 403042
ERR_ADMIN_PUSH = 403043
ERR_PLAN = 403044
ERR_MOB_CONFIG = 403045
ERR_BAlANCE_PAY_ORDERTYPE = 403046
ERR_PHONE_EXISTED = 403047
ERR_NOT_RESULT = 403048
ERR_REVIEW = 403049
ERR_USER_LEVEL_HAS_PAID = 403050
ERR_USER_BIND_OWN = 403051
ERR_PARENTUID_ERR = 403052
ERR_USER_DEL = 403053
ERR_SEARCH_ERR = 403054
ERR_LEVEL_REACH_TOP = 403055
ERR_USER_CHECK_ERR = 403056
ERR_PASSWORD_ERR = 403057
ERR_IS_BIND_PDD_ERR = 403058
ERR_MOB_SMS_NO_SAME = 403059
ERR_MOB_SMS_NO_EXISTS = 403060
// 404
ERR_USER_NOTFOUND = 404001
ERR_SUP_NOTFOUND = 404002
ERR_LEVEL_MAP = 404003
ERR_MOD_NOTFOUND = 404004
ERR_CLIPBOARD_PARSE = 404005
ERR_NOT_FAN = 404006
ERR_USER_LEVEL = 404007
ERR_LACK_PAY_CFG = 404008
ERR_NOT_LEVEL_TASK = 404009
ERR_ITEM_NOT_FOUND = 404012
ERR_WX_CHECKFILE_NOTFOUND = 404011

// 429 请求频繁
ERR_TOO_MANY_REQUESTS = 429000
// 500 系列
ERR = 500000
ERR_UNMARSHAL = 500001
ERR_UNKNOWN = 500002
ERR_SMS = 500003
ERR_ARKID_REGISTER = 500004
ERR_ARKID_WHITELIST = 500005
ERR_ARKID_LOGIN = 500006
ERR_CFG = 500007
ERR_DB_ORM = 500008
ERR_CFG_CACHE = 500009
ERR_ZHIMENG_CONVERT_ERR = 500010
ERR_ALIPAY_ERR = 500011
ERR_ALIPAY_ORDER_ERR = 500012
ERR_PAY_ERR = 500013
ERR_IS_BIND_THIRDOTHER = 500014
ERR_IS_BIND_THIRDOTHERWECHAT = 500015
ERR_INIT_RABBITMQ = 500016
)

var MsgFlags = map[int]string{
// 200
ERR_FILE_SAVE: "文件保存失败",
// 400
ERR_BAD_REQUEST: "请求失败..",
ERR_INVALID_ARGS: "请求参数错误",
ERR_API_RESPONSE: "API错误",
ERR_QINIUAPI_RESPONSE: "七牛请求API错误",
ERR_URL_TURNCHAIN: "转链失败",
ERR_NO_DATA: "暂无数据",
ERR_MOBILE_NIL: "电话号码不能为空",
ERR_MOBILE_MATH: "电话号码输入有误",
ERR_FILE_MAX_SIZE: "文件上传大小超限",
ERR_FILE_EXT: "文件类型不支持",
ERR_SIGN: "签名校验失败",
ERR_PROVIDER_RESPONSE: "提供商接口错误",
ERR_AES_ENCODE: "加解密错误",
ERR_ADMIN_API: "后台接口请求失败",
// 401
ERR_NOT_AUTH: "请登录后操作",
ERR_SMS_AUTH: "验证码过期或无效",
ERR_UNAUTHORIZED: "验证用户失败",
ERR_TOKEN_FORMAT: "Token格式不对",
ERR_TOKEN_GEN: "生成Token失败",
// 403
ERR_FORBIDEN: "禁止访问",
ERR_PLATFORM: "平台不支持",
ERR_MOBILE_EXIST: "该号码已注册过",
ERR_USER_NO_EXIST: "用户没有注册或账号密码不正确",
ERR_PASSWORD_ERR: "输入两次密码不一致",
ERR_RELATE_ERR: "推荐人不能是自己的粉丝",
ERR_PARENTUID_ERR: "推荐人不存在",
ERR_TOKEN_AUTH: "登录信息失效,请重新登录",
ERR_MOB_SMS_NO_AVA: "短信余额不足",
ERR_MOB_SMS_NO_SAME: "验证码不一致",
ERR_MOB_SMS_NO_EXISTS: "验证码已失效",
ERR_USER_IS_REG: "用户已注册",
ERR_MASTER_ID: "找不到对应站长的数据库",
ERR_CASH_OUT_TIME: "非可提现时间段",
ERR_CASH_OUT_USER_NOT_FOUND: "收款账号不存在",
ERR_CASH_OUT_FAIL: "提现失败",
ERR_CASH_OUT_FEE: "提现金额必须大于手续费",
ERR_CASH_OUT_TIMES: "当日提现次数已达上线",
ERR_CASH_OUT_MINI: "申请提现金额未达到最低金额要求",
ERR_CASH_OUT_MUT: "申请提现金额未达到整数倍要求",
ERR_CASH_OUT_NOT_DECIMAL: "提现申请金额只能是整数",
ERR_CASH_OUT_NOT_DAY_AVA: "不在可提现日期范围内",
ERR_USER_LEVEL_PAY_CHECK_TASK_NO_DONE: "请先完成其他任务",
ERR_USER_LEVEL_PAY_CHECK_NO_CROSS: "无法跨越升级",
ERR_USER_LEVEL_ORD_EXP: "付费订单已失效",
ERR_IS_BIND_THIRDPARTY: "该用户已经绑定了",
ERR_IS_BIND_THIRDOTHER: "该账号已经被绑定了",
ERR_IS_BIND_THIRDOTHERWECHAT: "该账号已经绑定了其他微信账号",
ERR_USER_LEVEL_UPDATE_CHECK_TASK_NO_DONE: "请完成指定任务",
ERR_USER_LEVEL_UPDATE_CHECK_NOT_FOUND_ORDER: "没有找到对应的订单",
ERR_USER_LEVEL_UPDATE_REPEAT: "不允许重复升级",
ERR_USER_NO_ACTIVE: "账户没激活",
ERR_USER_IS_BAN: "账户已被冻结",
ERR_SYSUNION_CONFIG: "联盟设置错误,请检查配置",
ERR_WECAHT_MINI: "小程序响应错误,请检查小程序配置",
ERR_WECAHT_MINI_CACHE: "获取小程序缓存失败",
ERR_WECAHT_MINI_DECODE: "小程序解密失败",
ERR_WECHAT_MINI_ACCESSTOKEN: "无法获取accesstoekn",
ERR_CURRENT_VIP_LEVEL_AUDITING: "当前等级正在审核中",
ERR_LEVEL_RENEW_SHOULD_KEEP_CURRENT: "续费只能在当前等级续费",
ERR_LEVEL_UPGRADE_APPLY_AUDITTING: "已有申请正在审核中,暂时不能申请",
ERR_LEVEL_TASK_PAY_TYPE: "任务付费类型错误",
ERR_BALANCE_NOT_ENOUGH: "余额不足",
ERR_ADMIN_PUSH: "后台MOB推送错误",
ERR_PLAN: "分拥方案出错",
ERR_MOB_CONFIG: "Mob 配置错误",
ERR_BAlANCE_PAY_ORDERTYPE: "无效余额支付订单类型",
ERR_PHONE_EXISTED: "手机号码已存在",
ERR_NOT_RESULT: "已加载完毕",
ERR_REVIEW: "审核模板错误",
ERR_USER_LEVEL_HAS_PAID: "该等级已经付过款",
ERR_IS_BIND_PDD_ERR: "获取PDD绑定信息失败",
// 404
ERR_USER_NOTFOUND: "用户不存在",
ERR_USER_DEL: "账号被删除,如有疑问请联系客服",
ERR_SUP_NOTFOUND: "上级用户不存在",
ERR_LEVEL_MAP: "无等级映射关系",
ERR_MOD_NOTFOUND: "没有找到对应模块",
ERR_CLIPBOARD_PARSE: "无法解析剪切板内容",
ERR_NOT_FAN: "没有粉丝",
ERR_CLIPBOARD_UNSUP: "不支持该平台",
ERR_USER_LEVEL: "该等级已不存在",
ERR_LACK_PAY_CFG: "支付配置不完整",
ERR_NOT_LEVEL_TASK: "等级任务查找错误",
ERR_ITEM_NOT_FOUND: "找不到对应商品",
ERR_WX_CHECKFILE_NOTFOUND: "找不到微信校验文件",
ERR_USER_BIND_OWN: "不能填写自己的邀请码",
// 429
ERR_TOO_MANY_REQUESTS: "请求频繁,请稍后重试",
// 500 内部错误
ERR: "接口错误",
ERR_SMS: "短信发送出错",
ERR_CFG: "服务器配置错误",
ERR_UNMARSHAL: "JSON解码错误",
ERR_UNKNOWN: "未知错误",
ERR_ARKID_LOGIN: "登录失败",
ERR_MOBILE_NO_EXIST: "该用户未设定手机号",
ERR_FORBIDEN_VALID: "验证码错误",
ERR_CFG_CACHE: "获取配置缓存失败",
ERR_DB_ORM: "数据操作失败",
ERR_REPEAT_RELATE: "重复关联",
ERR_ZHIMENG_CONVERT_ERR: "智盟转链失败",
ERR_MOB_FORBIDEN: "Mob调用失败",
ERR_ALIPAY_ERR: "支付宝参数错误",
ERR_ALIPAY_SETTING: "请在后台正确配置支付宝",
ERR_ALIPAY_ORDERTYPE: "无效支付宝订单类型",
ERR_ALIPAY_ORDER_ERR: "订单创建错误",
ERR_PAY_ERR: "未找到支付方式",
ERR_SEARCH_ERR: "暂无该分类商品",
ERR_LEVEL_REACH_TOP: "已经是最高等级",
ERR_USER_CHECK_ERR: "校验失败",
ERR_INIT_RABBITMQ: "连接mq失败",
}

+ 72
- 0
e/error.go 查看文件

@@ -0,0 +1,72 @@
package e

import (
"fmt"
"path"
"runtime"
)

type E struct {
Code int // 错误码
msg string // 报错代码
st string // 堆栈信息
}

func NewErrCode(code int) error {
if msg, ok := MsgFlags[code]; ok {
return E{code, msg, stack(3)}
}
return E{ERR_UNKNOWN, "unknown", stack(3)}
}

func NewErr(code int, msg string) error {
return E{code, msg, stack(3)}
}

func NewErrf(code int, msg string, args ...interface{}) error {
return E{code, fmt.Sprintf(msg, args), stack(3)}
}

func (e E) Error() string {
return e.msg
}

func stack(skip int) string {
stk := make([]uintptr, 32)
str := ""
l := runtime.Callers(skip, stk[:])
for i := 0; i < l; i++ {
f := runtime.FuncForPC(stk[i])
name := f.Name()
file, line := f.FileLine(stk[i])
str += fmt.Sprintf("\n%-30s[%s:%d]", name, path.Base(file), line)
}
return str
}

// ErrorIsAccountBan is 检查这个账号是否被禁用的错误
func ErrorIsAccountBan(e error) bool {
err, ok := e.(E)
if ok && err.Code == 403029 {
return true
}
return false
}

// ErrorIsAccountNoActive is 检查这个账号是否被禁用的错误
func ErrorIsAccountNoActive(e error) bool {
err, ok := e.(E)
if ok && err.Code == 403028 {
return true
}
return false
}

// ErrorIsUserDel is 检查这个账号是否被删除
func ErrorIsUserDel(e error) bool {
err, ok := e.(E)
if ok && err.Code == 403053 {
return true
}
return false
}

+ 8
- 0
e/set_cache.go 查看文件

@@ -0,0 +1,8 @@
package e

func SetCache(cacheTime int64) map[string]interface{} {
if cacheTime == 0 {
return map[string]interface{}{"cache_time": cacheTime}
}
return map[string]interface{}{"cache_time": cacheTime}
}

+ 1
- 0
go.mod 查看文件

@@ -15,6 +15,7 @@ require (
github.com/nilorg/sdk v0.0.0-20221104025912-4b6ccb7004d8
github.com/onsi/ginkgo v1.16.5 // indirect
github.com/onsi/gomega v1.19.0 // indirect
github.com/qiniu/api.v7/v7 v7.8.2
github.com/shopspring/decimal v1.2.0
github.com/syyongx/php2go v0.9.7
github.com/tidwall/gjson v1.14.1


+ 6
- 0
go.sum 查看文件

@@ -134,6 +134,8 @@ github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm4
github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gookit/color v1.3.6 h1:Rgbazd4JO5AgSTVGS3o0nvaSdwdrS8bzvIXwtK6OiMk=
github.com/gookit/color v1.3.6/go.mod h1:R3ogXq2B9rTbXoSHJ1HyUVAZ3poOJHpd9nQmyGZsfvQ=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
@@ -349,6 +351,8 @@ github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R
github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A=
github.com/qiniu/api.v7/v7 v7.8.2 h1:f08kI0MmsJNzK4sUS8bG3HDH67ktwd/ji23Gkiy2ra4=
github.com/qiniu/api.v7/v7 v7.8.2/go.mod h1:FPsIqxh1Ym3X01sANE5ZwXfLZSWoCUp5+jNI8cLo3l0=
github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 h1:OdAsTTz6OkFY5QxjkYwrChwuRruF69c169dPK26NUlk=
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
@@ -481,6 +485,8 @@ golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a h1:DcqTD9SDLc+1P/r1EmRBwnVsrOwW+kk2vWf9n+1sGhs=
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=


+ 9
- 0
kuaizhan/kuaizhan_test.go 查看文件

@@ -0,0 +1,9 @@
package kuaizhan

import (
"testing"
)

func TestKuaishou(t *testing.T) {
GetKuaizhanUrl("https://www.1234la.com/url/4444.html")
}

+ 84
- 0
kuaizhan/short_url.go 查看文件

@@ -0,0 +1,84 @@
package kuaizhan

import (
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/db"
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/db/offical"
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/db/offical/model"
zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils"
"fmt"
"strings"
"time"
"xorm.io/xorm"
)

func ShortUrlSend(engine *xorm.Engine, uid string, url string) string {
num := KuaizhanShortUrlNumGetSmsNum(engine, uid)
if num <= 0 {
return url
}
if strings.Contains(url, "kuaizhan") {

}
return url
}
func GetKuaizhanUrl(url string) {
method := "https://cloud.kuaizhan.com/api/v1/tbk/genKzShortUrl"
appKey := "7w2N8ohpFJxW"
appSecret := "11f7fa9a66c75229aca909b6c171cf84fa747ec4"
arg := map[string]string{
"appKey": appKey,
"url": url,
}
str := "appKey" + appKey + "url" + url
arg["sign"] = zhios_third_party_utils.Md5(appSecret + str + appSecret)
post, err := zhios_third_party_utils.CurlPost(method, arg, nil)
fmt.Println(string(post))
fmt.Println(err)
}

// 数量
func KuaizhanShortUrlNumGetSmsNum(engine *xorm.Engine, uid interface{}) int {
numData := offical.GetKuaizhanShortUrl(engine, uid)
num := 0
if numData != nil {
num = numData.Num
}
if num < 0 {
num = 0
}
return num
}

// 发送
func KuaizhanShortUrlSend(engine *xorm.Engine, args map[string]interface{}) error {
num := KuaizhanShortUrlNumGetSmsNum(engine, args["uid"])
//存入记录
ext := map[string]interface{}{
"post": args,
}
var record = model.KuaizhanShortUrlRecord{
OrdId: "",
Uid: int(zhios_third_party_utils.AnyToInt64(args["uid"])),
Amount: "1",
CostPrice: "",
Balance: zhios_third_party_utils.IntToStr(num - 1),
PayWay: 0,
State: 1,
Memo: "短链",
CreateAt: time.Now(),
UpdateAt: time.Now(),
TradeNo: "",
Type: 1,
OrdType: "buy",
Fee: "",
Ext: zhios_third_party_utils.SerializeStr(ext),
}
engine.InsertOne(&record)
sql := `UPDATE kuaizhan_short_url_num_list set num=num-%d WHERE uid=%s ;`
sql = fmt.Sprintf(sql, 1, args["uid"])
fmt.Println(sql)
nativeString, err := db.QueryNativeString(engine, sql)
fmt.Println(nativeString)
fmt.Println(err)
return nil
}

+ 21
- 0
kuaizhan/url.go 查看文件

@@ -0,0 +1,21 @@
package kuaizhan

import (
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/db/offical"
"github.com/syyongx/php2go"
"time"
"xorm.io/xorm"
)

func KuaizhanUrl(engine *xorm.Engine, args map[string]string) string {
kuaizhan_host := offical.SysCfgByKeyStr(engine, "kuaizhan_host")
if kuaizhan_host == "" {
return ""
}
numData := offical.GetKuaizhanUrl(engine, args["mid"])
if numData.EndTime.Unix() <= time.Now().Unix() {
return ""
}
kuaizhan_host += "?code=" + php2go.URLEncode(php2go.Base64Encode(args["url"]))
return kuaizhan_host
}

+ 279
- 0
md/cfg_key.go 查看文件

@@ -0,0 +1,279 @@
package md

// 获取用户的缓存key
const (
KEY_SYS_CFG_CACHE = "sys_cfg_cache"
FunctionPermissionCfgCacheKey = "%s:function_permission_cfg"
// 文件缓存的key
KEY_CFG_FILE_PVD = "file_provider" // 文件供应商
KEY_CFG_FILE_BUCKET = "file_bucket"
KEY_CFG_FILE_REGION = "file_bucket_region"
KEY_CFG_FILE_HOST = "file_bucket_host"
KEY_CFG_FILE_SCHEME = "file_bucket_scheme"
KEY_CFG_FILE_AK = "file_access_key"
KEY_CFG_FILE_SK = "file_secret_key"
KEY_CFG_FILE_MAX_SIZE = "file_user_upload_max_size"
KEY_CFG_FILE_EXT = "file_ext"
KEY_CFG_FILE_AVATAR_THUMBNAIL = "file_avatar_thumbnail" // 默认头像缩略图参数,宽高120px,格式webp.
// 智盟
KEY_CFG_ZM_JD_SITE_ID = "third_zm_jd_site_id" // 智盟京东联盟id
KEY_CFG_ZM_SMS_AK = "third_zm_sms_ak"
KEY_CFG_ZM_SMS_SK = "third_zm_sms_sk"
KEY_CFG_APP_NAME = "app_name"

KEY_CFG_WHITELIST = "api_cfg_whitelist" // API允许的访问的设置白名单

// 淘宝
KEY_CFG_TB_AUTH_AK = "third_taobao_auth_ak"
KEY_CFG_TB_AUTH_SK = "third_taobao_auth_sk"
KEY_CFG_TB_INVITER_CODE = "third_taobao_auth_inviter_code"
KEY_CFG_TB_AK = "third_taobao_ak"
KEY_CFG_TB_SK = "third_taobao_sk"
KEY_CFG_TB_PID = "third_taobao_pid" // 淘宝推广ID,如:mm_123_456_789,123是联盟ID,456是site_id,789是adzone_id
KEY_CFG_TB_SID = "third_taobao_sid" // 淘宝session id ,又称access_token

// 苏宁
KEY_CFG_SN_AK = "third_suning_ak"
KEY_CFG_SN_SK = "third_suning_sk"

KEY_CFG_JD_AK = ""
KEY_CFG_JD_SK = ""

KEY_CFG_KL_AK = "third_kaola_ak"
KEY_CFG_KL_SK = "third_kaola_sk"

KEY_CFG_VIP_AK = ""
KEY_CFG_VIP_SK = ""

// 自动任务配置
KEY_CFG_CRON_TB = "cron_order_taobao"
KEY_CFG_CRON_TBSETTLEORDER = "cron_order_taobao_settle_order"
KEY_CFG_CRON_JD = "cron_order_jd"
KEY_CFG_CRON_PDD = "cron_order_pdd"
KEY_CFG_CRON_PDD_SUCC = "cron_order_pdd_succ"
KEY_CFG_CRON_PDDBYCREATETIME = "cron_order_pdd_by_create_time"
KEY_CFG_CRON_PDDBYLOOPTIME = "cron_order_pdd_by_loop_time"
KEY_CFG_CRON_PDDBYLOOPMONTHTIME = "cron_order_pdd_by_loop_month_ago_time"
KEY_CFG_CRON_JDBYCREATETIME = "cron_order_jd_by_create_time"
KEY_CFG_CRON_JDBYSUCCESS = "cron_order_jd_by_success"
KEY_CFG_CRON_JDFAILBYCREATETIME = "cron_order_jd_fail_by_create_time"
KEY_CFG_CRON_PDDBYAGOTIME = "cron_order_pdd_by_ago_time"
KEY_CFG_CRON_PDDBYSTATUS = "cron_order_pdd_by_status"
KEY_CFG_CRON_PDDBYSTATUSSUCCESS = "cron_order_pdd_by_status_success"
KEY_CFG_CRON_PDDBYSTATUSFAIL = "cron_order_pdd_by_status_fail"
KEY_CFG_CRON_JDBYSTATUS = "cron_order_jd_by_status"
KEY_CFG_CRON_TBBYAGOTIME = "cron_order_tb_by_ago_time"
KEY_CFG_CRON_TBBYPAY = "cron_order_tb_by_pay"
KEY_CFG_CRON_TB12 = "cron_order_tb12"
KEY_CFG_CRON_TB13 = "cron_order_tb13"
KEY_CFG_CRON_TB3 = "cron_order_tb3"
KEY_CFG_CRON_TB14 = "cron_order_tb14"

KEY_CFG_CRON_PDDREFUND = "cron_order_pdd_refund"
KEY_CFG_CRON_TBREFUND = "cron_order_tb_refund"
KEY_CFG_CRON_WPHREFUND = "cron_order_wph_refund"
KEY_CFG_CRON_JDREFUND = "cron_order_jd_refund"
KEY_CFG_CRON_SN = "cron_order_suning"
KEY_CFG_CRON_VIP = "cron_order_vip"
KEY_CFG_CRON_KL = "cron_order_kaola"
KEY_CFG_CRON_DUOMAI = "cron_order_duomai"
KEY_CFG_CRON_HIS = "cron_order_his" // 迁移到历史订单
KEY_CFG_CRON_SETTLE = "cron_order_settle" //结算
KEY_CFG_CRON_FREE_SETTLE = "cron_order_free_settle" //结算
KEY_CFG_CRON_SECOND_FREE_SETTLE = "cron_order_second_free_settle"
KEY_CFG_CRON_THIRD_FREE_SETTLE = "cron_order_third_free_settle"
KEY_CFG_CRON_ACQUISTION_SETTLE = "cron_acquistion_settle" // 拉新结算
KEY_CFG_CRON_NEW_ACQUISTION_SETTLE = "cron_new_acquistion_settle" // 拉新结算
KEY_CFG_CRON_PUBLISHER = "cron_taobao_publisher" // 跟踪淘宝备案信息绑定会员运营id 针对小程序
KEY_CFG_CRON_AUTO_UN_FREEZE = "cron_auto_un_freeze"
KEY_CFG_CRON_MEITUAN = "cron_order_meituan_fxlm" //美团
KEY_CFG_CRON_MEITUANLM = "cron_order_meituan_lm" //美团联盟
KEY_CFG_CRON_MEITUANLM_START = "cron_order_meituan_lm_start" //美团联盟
KEY_CFG_CRON_ORDER_SUCCESS_CHECK = "cron_order_success_check"
KEY_CFG_CRON_MEITUAN_START = "cron_order_meituan_start" //美团联盟
KEY_CFG_CRON_STARBUCKS = "cron_order_starbucks" //海威星巴克
KEY_CFG_CRON_HWMOVIE = "cron_order_hw_movie" //海威电影票
KEY_CFG_CRON_MCDONALD = "cron_order_mcdonald" //海威麦当劳
KEY_CFG_CRON_NAYUKI = "cron_order_nayuki" //海威奈雪
KEY_CFG_CRON_BURGERKING = "cron_order_burger_king" //海威汉堡王
KEY_CFG_CRON_HEYTEA = "cron_order_heytea" //海威喜茶
KEY_CFG_CRON_TIKTOKLIFE = "cron_order_tik_tok_life" //
KEY_CFG_CRON_FAST_REFUND = "cron_order_fast_refund"
KEY_CFG_CRON_CHECK_GUIDE_STORE_ORDER = "cron_check_guide_store_order"
KEY_CFG_CRON_CHECK_BUCKLE_ORDER = "cron_check_buckle_order"
KEY_CFG_CRON_BUCKLE = "cron_order_buckle"
KEY_CFG_CRON_FAST_SUCCESS = "cron_order_fast_success"
KEY_CFG_CRON_PIZZA = "cron_order_pizza" //海威
KEY_CFG_CRON_WALLACE = "cron_order_wallace" //海威
KEY_CFG_CRON_TOURISM = "cron_order_tourism" //海威
KEY_CFG_CRON_NEAR = "cron_order_near" //海威
KEY_CFG_CRON_FLOWERCAKE = "cron_order_flowerCake" //海威
KEY_CFG_CRON_DELIVERY = "cron_order_delivery" //海威
KEY_CFG_CRON_TO_KFC = "cron_order_to_kfc" //
KEY_CFG_CRON_PAGODA = "cron_order_pagoda" //
KEY_CFG_CRON_LUCKIN = "cron_order_luckin" //
KEY_CFG_CRON_STATIONMEITUANLM = "cron_order_station_meituan_lm" //站长美团联盟
KEY_CFG_CRON_MEITUANOFFICIAL = "cron_order_meituan_official" //美团联盟智莺
KEY_CFG_CRON_OILSTATION = "cron_order_oilstation" //加油
KEY_CFG_CRON_BRIGHTOILSTATION = "cron_order_bright_oilstation" //加油
KEY_CFG_CRON_KFC = "cron_order_kfc" //肯德基
KEY_CFG_CRON_CINEMA = "cron_order_cinema" //电影票
KEY_CFG_CRON_OilRequest = "cron_order_oilrequest" //加入主动请求抓单
KEY_CFG_CRON_AGOTB = "cron_order_agotaobao" //n天前的淘宝订单
KEY_CFG_CRON_CREDIT_CARD = "cron_order_credit_card"
KEY_CFG_CRON_ORDER_STAT = "cron_order_stat" // 订单统计任务
KEY_CFG_CRON_CARD_UPDATE = "cron_card_update" // 权益卡更新
KEY_CFG_CRON_USER_LV_UP_SETTLE = "cron_user_lv_up_settle" //会员费订单结算
KEY_CFG_CRON_DUOYOUORD_SETTLE = "cron_duoyou_settle" //会员费订单结算
KEY_CFG_CRON_LIANLIAN_SETTLE = "cron_lianlian_settle" //会员费订单结算
KEY_CFG_CRON_SWIPE_SETTLE = "cron_swipe_settle"
KEY_CFG_CRON_AGGREGATION_RECHARGE_SETTLE = "cron_aggregation_recharge_settle"
KEY_CFG_CRON_ACQUISITION_CONDITION = "cron_acquisition_condition"
KEY_CFG_CRON_ACQUISITION_CONDITION_BY_LV = "cron_acquisition_condition_by_lv"
KEY_CFG_CRON_ACQUISITION_REWARD = "cron_acquisition_reward"
KEY_CFG_CRON_PLAYLET_SETTLE = "cron_playlet_settle"
KEY_CFG_CRON_TIKTOK_AUTH = "cron_tik_tok_auth"
KEY_CFG_CRON_TASKBOX_SETTLE = "cron_task_box_settle" //会员费订单结算
KEY_CFG_CRON_PRIVILEGE_CARD_SETTLE = "cron_privilege_card_settle" //权益卡订单结算
KEY_CFG_CRON_CARD_RETURN = "cron_card_return" //权益卡退款
KEY_CFG_CRON_PUBLISHER_RELATION = "cron_taobao_publisher_relation" //获取淘宝渠道
KEY_CFG_CRON_PUBLISHER_RELATION_NEW = "cron_taobao_publisher_relation_new" //获取淘宝渠道

KEY_CFG_CRON_DTKBRAND = "cron_dtk_brand" //大淘客品牌信息
KEY_CFG_CRON_PUBLISHER_RELATION_BIND = "cron_taobao_publisher_relation_bind" //获取淘宝渠道绑定
KEY_CFG_CRON_GOODS_SHELF = "cron_goods_shelf" //商品上下架定时任务
KEY_CFG_CRON_DIDI_ENERGY = "cron_order_didi_energy" //
KEY_CFG_CRON_T3_CAR = "cron_order_t3_car" //
KEY_CFG_CRON_DIDI_ONLINE_CAR = "cron_order_didi_online_car" //
KEY_CFG_CRON_KING_FLOWER = "cron_order_king_flower" //
KEY_CFG_CRON_DIDI_CHAUFFEUR = "cron_order_didi_chauffeur" //
KEY_CFG_CRON_PLAYLET_ORDER = "cron_order_playlet_order" //
KEY_CFG_CRON_PLAYLET_GOODS = "cron_order_playlet_goods" //
KEY_CFG_CRON_CARD_CHECK_RETURN = "cron_card_check_return" //
KEY_CFG_CRON_CARD_CHECK_UPDATE = "cron_card_check_update" //
KEY_CFG_CRON_DIDI_FREIGHT = "cron_order_didi_freight" //
KEY_CFG_CRON_TB_PUNISH_REFUND = "cron_order_tb_punish_refund"
KEY_CFG_CRON_TIKTOK = "cron_order_tikTok"
KEY_CFG_CRON_ELM = "cron_order_elm"
KEY_CFG_CRON_AUTO_ADD_TIKTOK_GOODS = "cron_order_auto_add_tiktok_goods"
KEY_CFG_CRON_TIKTOKOwn = "cron_order_tikTokOwn"
KEY_CFG_CRON_TIKTOKCsjp = "cron_order_tikTokCsjp"
KEY_CFG_CRON_TIKTOKCsjpLive = "cron_order_tikTokCsjpLive"
KEY_CFG_CRON_TIKTOKOwnCsjp = "cron_order_tikTokOwnCsjp"
KEY_CFG_CRON_TIKTOKOwnCsjpLive = "cron_order_tikTokOwnCsjpLive"
KEY_CFG_CRON_TIKTOKOwnCsjpActivity = "cron_order_tikTokOwnCsjpActivity"
KEY_CFG_CRON_PlayLet_Total = "cron_playlet_total"
KEY_CFG_CRON_TIKTOKOwnCreate = "cron_order_tikTokOwnCreate"
KEY_CFG_CRON_KuaishouOwn = "cron_order_kuaishouOwn"
KEY_CFG_CRON_KuaishouOwnCreate = "cron_order_kuaishouOwnCreate"
KEY_CFG_CRON_TIKTOKOwnACtivity = "cron_order_tikTokOwnActivity"
KEY_CFG_CRON_DUOYOUORD = "cron_order_DouYouOrd"
KEY_CFG_CRON_TASKBOX = "cron_order_TaskBox"
KEY_CFG_CRON_TASKBOXSECOND = "cron_order_TaskBoxSecond"
KEY_CFG_CRON_TIKTOKOwnMixH5 = "cron_order_tikTokOwnMixH5"

KEY_CFG_CRON_TIKTOKLIVE_UPDATE = "cron_order_tikTokLive_update"
KEY_CFG_CRON_KUAISHOU = "cron_order_kuaishou"
KEY_CFG_CRON_KUAISHOUOFFICIAL = "cron_order_kuaishou_official"
KEY_CFG_CRON_KUAISHOUOFFICIALLive = "cron_order_kuaishou_official_live"
KEY_CFG_CRON_MEITUANFFICIAL = "cron_order_meituan_official"
KEY_CFG_CRON_TIKTOKLIVE = "cron_order_tikTok_live"
KEY_CFG_CRON_TIKTOKLIVEOWN = "cron_order_tikTok_live_own"
KEY_CFG_CRON_TIKTOKACTIVITY = "cron_order_tikTok_activity"
KEY_CFG_CRON_KUAISHOULIVE = "cron_order_kuaishou_live"

ZhimengCronPlayletVideoOrder = "cron_playlet_video_order" //短剧订单
ZhimengCronPlayletAdvOrder = "cron_playlet_adv_order" //短剧广告订单
ZhimengCronPlayletVideoOrderYesterDay = "cron_playlet_video_order_yesterday"
ZhimengCronPlayletVideoOrderMonth = "cron_playlet_video_order_month"
ZhimengCronPlayletAdvOrderYesterDay = "cron_playlet_adv_order_yesterday"
ZhimengCronPlayletAdvOrderMonth = "cron_playlet_adv_order_month"
ZhimengCronPlayletAdvOrderYesterDayToMoney = "cron_playlet_adv_order_yesterday_to_money"
KEY_CFG_TIK_TOK_TEAM_ORDER_PAY = "cron_tik_tok_team_order_pay"
KEY_CFG_KUAISHOU_TEAM_ORDER_PAY = "cron_kuaishou_team_order_pay"
KEY_CFG_KUAISHOU_TEAM_ORDER_UPDATE = "cron_kuaishou_team_order_update"
KEY_CFG_KUAISHOU_AUTH = "cron_kuaishou_auth"
KEY_CFG_VERIFY = "cron_verify"
KEY_CFG_TIK_TOK_TEAM_ORDER_UPDATE = "cron_tik_tok_team_order_update"
KEY_CFG_TIK_TOK_TEAM_USER_BIND_BUYINID = "cron_tik_tok_team_user_bind_buyinid"
// 自动任务运行时设置
KEY_CFG_CRON_TIME_PIZZA = "crontab_order_time_pizza"
KEY_CFG_CRON_TIME_WALLACE = "crontab_order_time_wallace"
KEY_CFG_CRON_TIME_TOURISM = "crontab_order_time_tourism"
KEY_CFG_CRON_TIME_NEAR = "crontab_order_time_pizza"
KEY_CFG_CRON_TIME_FLOWERCAKE = "crontab_order_time_flowerCake"
KEY_CFG_CRON_TIME_DELIVERY = "crontab_order_time_delivery"
KEY_CFG_CRON_TIME_TIKTOK = "crontab_order_time_tikTok"
KEY_CFG_CRON_TIME_ELM = "crontab_order_time_elm"
KEY_CFG_CRON_TIME_TIKTOKOwn = "crontab_order_time_tikTokOwn"
KEY_CFG_CRON_TIME_TIKTOKOwnCreate = "crontab_order_time_tikTokOwnCreate"
KEY_CFG_CRON_TIME_KuaishouOwn = "crontab_order_time_kuaishouOwn"
KEY_CFG_CRON_TIME_KuaishouOwnCreate = "crontab_order_time_kuaishouOwnCreate"
KEY_CFG_CRON_TIME_TIKTOKOwnActivity = "KEY_CFG_CRON_TIME_TIKTOKOwnActivity"
KEY_CFG_CRON_TIME_TIKTOKOwnMix = "KEY_CFG_CRON_TIME_TIKTOKOwnMix"
KEY_CFG_CRON_TIME_TIKTOKOwnLive = "crontab_order_time_tikTokOwnLive"
KEY_CFG_CRON_TIME_KUAISHOU = "crontab_order_time_kuaishou"
KEY_CFG_CRON_TIME_TIKTOKLIVE = "crontab_order_time_tikTok_live"
KEY_CFG_CRON_TIME_KUAISHOULIVE = "crontab_order_time_kuaishou_live"
KEY_CFG_CRON_TIME_TB = "crontab_order_time_taobao"
KEY_CFG_CRON_TIME_CSJP = "crontab_order_time_csjp"
KEY_CFG_CRON_TIME_KUAISHOU_OFFICIAL = "crontab_order_time_kuaishou_official"
KEY_CFG_CRON_TIME_KUAISHOU_OFFICIAL_LIVE = "crontab_order_time_kuaishou_official_live"
KEY_CFG_CRON_TIME_MEITUAN_OFFICIAL = "crontab_order_time_meituan_official"
KEY_CFG_CRON_TIME_CSJP_Live = "crontab_order_time_csjp_live"
KEY_CFG_CRON_TIME_OWN_CSJP = "crontab_order_time_own_csjp"
KEY_CFG_CRON_TIME_TIKTOK_TEAM_ORDER = "crontab_order_time_tiktok_team_order"
KEY_CFG_CRON_TIME_OWN_CSJP_Live = "crontab_order_time_own_csjp_live"
KEY_CFG_CRON_TIME_OWN_CSJP_ACTIVITY = "crontab_order_time_own_csjp_activity"
KEY_CFG_CRON_TIME_TBREFUND = "crontab_order_time_taobao_refund"
KEY_CFG_CRON_TIME_TBPUNISHREFUND = "crontab_order_time_taobao_punish_refund_new"
KEY_CFG_CRON_TIME_JD = "crontab_order_time_jd"
KEY_CFG_CRON_TIME_PDD = "crontab_order_time_pdd"
KEY_CFG_CRON_TIME_TBBYCREATETIME = "crontab_order_time_tb_by_create_time"
KEY_CFG_CRON_TIME_TBBYPAY = "crontab_order_time_tb_by_pay"
KEY_CFG_CRON_TIME_TB12 = "crontab_order_time_tb12"
KEY_CFG_CRON_TIME_TB13 = "crontab_order_time_tb13"
KEY_CFG_CRON_TIME_TB14 = "crontab_order_time_tb14"
KEY_CFG_CRON_TIME_TB3 = "crontab_order_time_tb3"
KEY_CFG_CRON_TIME_TBBYSETTLE = "crontab_order_time_tb_by_settle"
KEY_CFG_CRON_TIME_PDDBYCREATETIME = "crontab_order_time_pdd_by_create_time"
KEY_CFG_CRON_TIME_JDBYCREATETIME = "crontab_order_time_jd_by_create_time"
KEY_CFG_CRON_TIME_JDBYSUCCESS = "crontab_order_time_jd_by_success"
KEY_CFG_CRON_TIME_JDFAILBYCREATETIME = "crontab_order_time_jd_fail_by_create_time"
KEY_CFG_CRON_TIME_PDDBYAGOTIME = "crontab_order_time_pdd_by_ago_time"
KEY_CFG_CRON_TIME_PDDBYSTATUSSUCCESS = "crontab_order_time_pdd_by_status_success"
KEY_CFG_CRON_TIME_PDDBYSTATUSFAIL = "crontab_order_time_pdd_by_status_fail"
KEY_CFG_CRON_TIME_PDDBYSTATUS = "crontab_order_time_pdd_by_status"
KEY_CFG_CRON_TIME_JDBYSTATUS = "crontab_order_time_jd_by_status"
KEY_CFG_CRON_TIME_SN = "crontab_order_time_suning"
KEY_CFG_CRON_TIME_VIP = "crontab_order_time_vip"
KEY_CFG_CRON_TIME_KL = "crontab_order_time_kaola"
KEY_CFG_CRON_TIME_DUOMAI = "crontab_order_time_duomai"
KEY_CFG_CRON_TIME_PUBLISHER = "crontab_taobao_time_publisher" // 跟踪淘宝备案信息绑定会员运营id 针对小程序
KEY_CFG_CRON_TIME_MEITUAN = "crontab_order_time_meituan" //美团
KEY_CFG_CRON_TIME_MEITUANLM = "crontab_order_time_meituan_lm" //美团联盟
KEY_CFG_CRON_TIME_MEITUANLMSTART = "crontab_order_time_meituan_lm_start" //美团联盟
KEY_CFG_CRON_TIME_MEITUANSTART = "crontab_order_time_meituan_start" //美团联盟
KEY_CFG_CRON_TIME_STATIONMEITUANLM = "crontab_order_time_station_meituan_lm" //美团联盟
KEY_CFG_CRON_TIME_OILSTATION = "crontab_order_time_oilstation" //加油
KEY_CFG_CRON_TIME_BRIGHT_OILSTATION = "crontab_order_time_bright_oilstation" //加油
KEY_CFG_CRON_TIME_KFC = "crontab_order_time_kfc" //肯德基
KEY_CFG_CRON_TIME_CINEMA = "crontab_order_time_cinema" //电影票
KEY_CFG_CRON_TIME_STARBUCKS = "crontab_order_time_starbucks" //海威星巴克
KEY_CFG_CRON_TIME_MCDONALD = "crontab_order_time_mcdonald" //海威麦当劳
KEY_CFG_CRON_TIME_NAYUKI = "crontab_order_time_nayuki" //海威奈雪
KEY_CFG_CRON_TIME_BURGERKING = "crontab_order_time_burger_king" //海威汉堡王
KEY_CFG_CRON_TIME_HEYTEA = "crontab_order_time_heytea" //海威喜茶
KEY_CFG_CRON_TIME_HWMOVIE = "crontab_order_time_hw_movie" //海威电影票
KEY_CFG_CRON_TIME_TIKTOKLIFE = "crontab_order_time_tik_tok_life" //海威电影票
KEY_CFG_CRON_TIME_PAGODA = "crontab_order_time_pagoda" //
KEY_CFG_CRON_TIME_TO_KFC = "crontab_order_time_to_kfc" //
KEY_CFG_CRON_TIME_LUCKIN = "crontab_order_time_luckin" //
KEY_CFG_CRON_TIME_DIDI_ENERGY = "crontab_order_time_didi_energy" //
KEY_CFG_CRON_TIME_T3_CAR = "crontab_order_time_t3_car" //
KEY_CFG_CRON_TIME_DIDI_ONLINE_CAR = "crontab_order_time_didi_online_car" //
KEY_CFG_CRON_TIME_KING_FLOWER = "crontab_order_time_king_flower" //
KEY_CFG_CRON_TIME_DIDI_FREIGHT = "crontab_order_time_didi_freight" //
KEY_CFG_CRON_TIME_DIDI_CHAUFFEUR = "crontab_order_time_didi_chauffeur" //
KEY_CFG_CRON_USER_RELATE = "cron_user_relate"
)

+ 62
- 0
md/file.go 查看文件

@@ -0,0 +1,62 @@
package md

// 用户拥有上传权限的目录, 目录ID

const (
FILE_DIR_FEEDBACK = "feedback"
FILE_DIR_AVATAR = "avatar"
FILE_DIR_QRCODE = "qrcode"
FILE_DIR_STYLE = "style"
FILE_DIR_O2O = "O2OStore"
FILE_DIR_MALL_AFTER_SALE = "Proprietary_After_Service"
FILE_DIR_IMGREWARD = "img_reward"
FILE_DOCTOR = "doctor"
)

var (
FileUserDir = map[string]string{
FILE_DIR_FEEDBACK: "4", // 用户反馈
FILE_DIR_AVATAR: "5", // 用户头像
FILE_DIR_QRCODE: "6", // 用户微信二维码
FILE_DIR_STYLE: "7", // 用户样式
FILE_DIR_O2O: "8", //O2O商家上传
FILE_DIR_MALL_AFTER_SALE: "9", // 售后图片上传
FILE_DIR_IMGREWARD: "10", //拍立返
FILE_DOCTOR: "11", //数字医生
}
)

// 文件回调信息
type FileCallback struct {
Uid string `json:"uid"`
DirId string `json:"dir_id"`
Provider string `json:"provider"` // 供应商
FileName string `json:"fname"` // 原文件名
FileSize string `json:"fsize"`
Hash string `json:"hash"`
Bucket string `json:"bucket"`
Mime string `json:"mime"`
Width string `json:"w,omitempty"`
Height string `json:"h,omitempty"`
Time string `json:"time"` // 默认一个小时内要上传完毕,否则超时
Sign string `json:"sign"` // 签名
}

type FileList struct {
Path string `json:"path"`
DirId int `json:"dir_id"`
FileName string `json:"f_name"` // 显示名称
StgName string `json:"stg_name"` // 存储名字
Ext string `json:"ext"` // 后缀名, png,jpg等
FileSize string `json:"f_size"`
Provider string `json:"provider"` // 存储供应商
Hash string `json:"hash"`
Bucket string `json:"bucket"`
Width int `json:"w"`
Height int `json:"h"`
Mime string `json:"mime"`
IsAdm bool `json:"is_adm"` //是否管理后台上传
IsDir bool `json:"is_dir"` //是否文件夹
CreateAt int `json:"create_at"`
Url string `json:"url"`
}

+ 67
- 0
qiniuyun/api.go 查看文件

@@ -0,0 +1,67 @@
package qiniu

import (
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/e"
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/md"
zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils"
"fmt"
"strings"
)

func ImgReqUpload(arg map[string]string, uid, dirName, fname, callbackUrl string, fsize int64) (interface{}, error) {
ext := zhios_third_party_utils.FileExt(fname)
if err := initStg(arg, fsize, ext); err != nil {
return nil, err
}
newName := dirName + "_" + fmt.Sprintf("%010s", uid)
// 默认都加时间戳
newName += "_" + zhios_third_party_utils.FormatNanoUnix() + zhios_third_party_utils.RandString(4, "0123456789")
newName += "." + ext
f := &md.FileCallback{
Uid: uid,
DirId: md.FileUserDir[dirName],
FileName: newName,
}
return ReqImgUpload(f, callbackUrl), nil
}

func initStg(stgInfo map[string]string, fsize int64, ext string) error {
// todo 目前仅支持七牛
if v, ok := stgInfo[md.KEY_CFG_FILE_REGION]; !ok || v == "" {
return e.NewErrCode(e.ERR_CFG)
}
if v, ok := stgInfo[md.KEY_CFG_FILE_AK]; !ok || v == "" {
return e.NewErrCode(e.ERR_CFG)
}
if v, ok := stgInfo[md.KEY_CFG_FILE_SK]; !ok || v == "" {
return e.NewErrCode(e.ERR_CFG)
}
if v, ok := stgInfo[md.KEY_CFG_FILE_BUCKET]; !ok || v == "" {
return e.NewErrCode(e.ERR_CFG)
}
if v, ok := stgInfo[md.KEY_CFG_FILE_SCHEME]; !ok || v == "" {
stgInfo[md.KEY_CFG_FILE_SCHEME] = "http"
}
Init(stgInfo[md.KEY_CFG_FILE_AK], stgInfo[md.KEY_CFG_FILE_SK], stgInfo[md.KEY_CFG_FILE_BUCKET], stgInfo[md.KEY_CFG_FILE_REGION], stgInfo[md.KEY_CFG_FILE_SCHEME])
if v, ok := stgInfo[md.KEY_CFG_FILE_HOST]; !ok || v == "" {
var err error
stgInfo[md.KEY_CFG_FILE_HOST], err = BucketGetDomain(stgInfo[md.KEY_CFG_FILE_BUCKET])
if err != nil {
return e.NewErrCode(e.ERR_CFG)
}
}
// 头像缩略图参数
if v, ok := stgInfo[md.KEY_CFG_FILE_AVATAR_THUMBNAIL]; !ok || v == "" {
stgInfo[md.KEY_CFG_FILE_AVATAR_THUMBNAIL] = "?imageView2/1/w/200/h/200/format/png"
}

// 检查文件大小限制
if v, ok := stgInfo[md.KEY_CFG_FILE_MAX_SIZE]; ok && v != "" && zhios_third_party_utils.StrToInt64(v) < fsize {
return e.NewErrCode(e.ERR_FILE_MAX_SIZE)
}
// 检查文件后缀
if v, ok := stgInfo[md.KEY_CFG_FILE_EXT]; ok && v != "" && !strings.Contains(v, ext) {
return e.NewErrCode(e.ERR_FILE_EXT)
}
return nil
}

+ 16
- 0
qiniuyun/bucket_create.go 查看文件

@@ -0,0 +1,16 @@
package qiniu

import (
"github.com/qiniu/api.v7/v7/auth"
"github.com/qiniu/api.v7/v7/storage"
)

func BucketCreate() error {
mac := auth.New(AK, SK)
cfg := storage.Config{
// 是否使用https域名进行资源管理
UseHTTPS: false,
}
bucketManager := storage.NewBucketManager(mac, &cfg)
return bucketManager.CreateBucket("", storage.RIDHuanan)
}

+ 18
- 0
qiniuyun/bucket_delete.go 查看文件

@@ -0,0 +1,18 @@
package qiniu

import (
"github.com/qiniu/api.v7/v7/auth"
"github.com/qiniu/api.v7/v7/storage"
)

func BucketDelete(bucketName string) error {
mac := auth.New(AK, SK)

cfg := storage.Config{
// 是否使用https域名进行资源管理
UseHTTPS: false,
}

bucketManager := storage.NewBucketManager(mac, &cfg)
return bucketManager.DropBucket(bucketName)
}

+ 18
- 0
qiniuyun/bucket_get_domain.go 查看文件

@@ -0,0 +1,18 @@
package qiniu

import (
"github.com/qiniu/api.v7/v7/auth"
"github.com/qiniu/api.v7/v7/storage"
)

func BucketGetDomain(bucketName string) (string, error) {
mac := auth.New(AK, SK)

cfg := storage.Config{UseHTTPS: false}
bucketManager := storage.NewBucketManager(mac, &cfg)
b, err := bucketManager.ListBucketDomains(bucketName)
if err != nil {
return "", err
}
return b[0].Domain, nil
}

+ 20
- 0
qiniuyun/init.go 查看文件

@@ -0,0 +1,20 @@
package qiniu

import zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils"

var (
AK = "MmxNdai23egjNUHjdzEVaTPdPCIbWzENz9BQuak3"
SK = "mElaFlM9O16rXp-ihoQdJ9KOH56naKm3MoyQBA59"
BUCKET = "dev-fnuoos" // 桶子名称
BUCKET_SCHEME = "http"
BUCKET_REGION = "up-z2.qiniup.com"
Expires uint64 = 3600
)

func Init(ak, sk, bucket, region, scheme string) {
AK, SK, BUCKET, BUCKET_REGION, BUCKET_SCHEME = ak, sk, bucket, region, scheme
}

func Sign(t string) string {
return zhios_third_party_utils.Md5(AK + SK + t)
}

+ 42
- 0
qiniuyun/req_img_upload.go 查看文件

@@ -0,0 +1,42 @@
package qiniu

import (
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/md"
zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils"
"time"

"github.com/qiniu/api.v7/v7/auth/qbox"
_ "github.com/qiniu/api.v7/v7/conf"
"github.com/qiniu/api.v7/v7/storage"
)

// 请求图片上传地址信息
func ReqImgUpload(f *md.FileCallback, callbackUrl string) interface{} {
if ext := zhios_third_party_utils.FileExt(f.FileName); ext == "png" || ext == "jpg" || ext == "jpeg" || ext == "gif" || ext == "bmp" || ext == "webp" {
f.Width = "$(imageInfo.width)"
f.Height = "$(imageInfo.height)"
}
f.Provider = "qiniu"
f.FileSize = "$(fsize)"
f.Hash = "$(etag)"
f.Bucket = "$(bucket)"
f.Mime = "$(mimeType)"
f.Time = zhios_third_party_utils.Int64ToStr(time.Now().Unix())
f.Sign = Sign(f.Time)
putPolicy := storage.PutPolicy{
Scope: BUCKET + ":" + f.FileName, // 使用覆盖方式时候必须请求里面有key,否则报错
Expires: Expires,
ForceSaveKey: true,
SaveKey: f.FileName,
//MimeLimit: "image/*", // 只允许上传图片
CallbackURL: callbackUrl,
CallbackBody: zhios_third_party_utils.SerializeStr(f),
CallbackBodyType: "application/json",
}
return &struct {
Method string `json:"method"`
Key string `json:"key"`
Host string `json:"host"`
Token string `json:"token"`
}{Key: f.FileName, Method: "POST", Host: BUCKET_SCHEME + "://" + BUCKET_REGION, Token: putPolicy.UploadToken(qbox.NewMac(AK, SK))}
}

Loading…
取消
儲存