由gopath形式改为module

This commit is contained in:
kongyuebin
2021-04-27 15:33:49 +08:00
parent aef4dbb33c
commit 77d895e83a
1117 changed files with 332447 additions and 20 deletions

View File

@@ -0,0 +1,68 @@
/***************************************************
** @Desc : This file for 银行编码
** @Time : 19.12.4 10:42
** @Author : Joker
** @File : bank_info
** @Last Modified by : Joker
** @Last Modified time: 19.12.4 10:42
** @Software: GoLand
****************************************************/
package enum
const (
ICBC = "ICBC"
ABC = "ABC"
BOC = "BOC"
CCB = "CCB"
BOCOM = "BOCOM"
CNCB = "CNCB"
CEB = "CEB"
HXB = "HXB"
CMBC = "CMBC"
GDB = "GDB"
CMB = "CMB"
CIB = "CIB"
SPDB = "SPDB"
PSBC = "PSBC"
PAB = "PAB"
NJCB = "NJCB"
NBCB = "NBCB"
WZCB = "WZCB"
CSCB = "CSCB"
CZCB = "CZCB"
CCQTGB = "CCQTGB"
SHRCB = "SHRCB"
BJRCB = "BJRCB"
SDB = "SDB"
)
var bankInfo = map[string]string{
ICBC: "中国工商银行",
ABC: "中国农业银行",
BOC: "中国银行",
CCB: "中国建设银行",
BOCOM: "交通银行",
CNCB: "中信银行",
CEB: "中国光大银行",
HXB: "华夏银行",
CMBC: "中国民生银行",
GDB: "广发银行",
CMB: "招商银行",
CIB: "兴业银行",
SPDB: "浦发银行",
PSBC: "中国邮政储蓄银行",
PAB: "平安银行",
NJCB: "南京银行",
NBCB: "宁波银行",
WZCB: "温州市商业银行",
CSCB: "长沙银行",
CZCB: "浙江稠州商业银行",
CCQTGB: "重庆三峡银行",
SHRCB: "上海农村商业银行",
BJRCB: "北京农商行",
SDB: "深圳发展银行",
}
func GetBankInfo() map[string]string {
return bankInfo
}

34
merchant/sys/enum/conf.go Normal file
View File

@@ -0,0 +1,34 @@
/***************************************************
** @Desc : This file for 配置常量
** @Time : 2019.04.01 11:45
** @Author : Joker
** @File : strings
** @Last Modified by : Joker
** @Last Modified time: 2019-11-29 11:05:48
** @Software: GoLand
****************************************************/
package enum
// 短信配置
// 对接云片
const (
ApiKey = "fds4s3c02se6fseab1sba"
TPL1 = 33236
SendSmsUrl = "https://sms.yunpian.com/v2/sms/tpl_single_send.json"
)
// session 配置
const (
SessionPath = "./sys/temp" // 保存路径
SessionExpireTime = 9600 // 有效时间,秒
CookieExpireTime = 1800 // 有效时间,秒
SmsCookieExpireTime = 60 // 有效时间,秒
LocalSessionName = "JOKERSession" // 客户端session名称
)
// 提现限制金额
const (
WithdrawalMaxAmount = 45000
WithdrawalMinAmount = 2
SettlementFee = 2 // 提现单笔手续费
)

View File

@@ -0,0 +1,26 @@
/***************************************************
** @Desc : This file for 系统常量
** @Time : 19.11.30 11:28
** @Author : Joker
** @File : constant
** @Last Modified by : Joker
** @Last Modified time: 19.11.30 11:28
** @Software: GoLand
****************************************************/
package enum
const (
UserSession = "business_user"
UserCookie = "user_cookie_md5"
DoMainUrl = "/index/ui/"
PublicAccount = "1" // 对公帐户
PrivateDebitAccount = "0" // 对私借记卡
SettleSingle = "SELFHELP_SETTLE" // 单笔代付
ExcelModelName = "batch_daifa_template.xlsx"
ExcelModelPath = "static/excel/batch_daifa_template.xlsx"
ExcelPath = "static/excel/temp/"
ExcelDownloadPath = "static/excel/download/"
)

View File

@@ -0,0 +1,60 @@
/***************************************************
** @Desc : This file for 支付方式
** @Time : 19.12.3 15:24
** @Author : Joker
** @File : pay_type
** @Last Modified by : Joker
** @Last Modified time: 19.12.3 15:24
** @Software: GoLand
****************************************************/
package enum
const (
WEIXIN_SCAN = "WEIXIN_SCAN"
WEIXIN_H5 = "WEIXIN_H5"
WEIXIN_SYT = "WEIXIN_SYT"
ALI_SCAN = "ALI_SCAN"
ALI_H5 = "ALI_H5"
ALI_SYT = "ALI_SYT"
QQ_SCAN = "QQ_SCAN"
QQ_H5 = "QQ_H5"
QQ_SYT = "QQ_SYT"
UNION_SCAN = "UNION_SCAN"
UNION_H5 = "UNION_H5"
UNION_PC_WAP = "UNION_PC_WAP"
UNION_SYT = "UNION_SYT"
UNION_FAST = "UNION_FAST"
BAIDU_SCAN = "BAIDU_SCAN"
BAIDU_H5 = "BAIDU_H5"
BAIDU_SYT = "BAIDU_SYT"
JD_SCAN = "JD_SCAN"
JD_H5 = "JD_H5"
JD_SYT = "JD_SYT"
)
var payType = map[string]string{
WEIXIN_SCAN: "微信扫码",
WEIXIN_H5: "微信H5",
WEIXIN_SYT: "微信收银台",
ALI_SCAN: "支付宝扫码",
ALI_H5: "支付宝H5",
ALI_SYT: "支付宝收银台",
QQ_SCAN: "QQ扫码",
QQ_H5: "QQ-H5",
QQ_SYT: "QQ收银台",
UNION_SCAN: "银联扫码",
UNION_H5: "银联H5",
UNION_PC_WAP: "银联pc-web",
UNION_SYT: "银联收银台",
UNION_FAST: "银联快捷",
BAIDU_SCAN: "百度钱包扫码",
BAIDU_H5: "百度钱包H5",
BAIDU_SYT: "百度钱包收银台",
JD_SCAN: "京东扫码",
JD_H5: "京东H5",
JD_SYT: "京东收银台",
}
func GetPayType() map[string]string {
return payType
}

View File

@@ -0,0 +1,16 @@
/***************************************************
** @Desc : This file for 正则表达式
** @Time : 19.12.5 10:25
** @Author : Joker
** @File : regular_expression
** @Last Modified by : Joker
** @Last Modified time: 19.12.5 10:25
** @Software: GoLand
****************************************************/
package enum
const (
PasswordReg = `^[a-zA-Z]{1}([a-zA-Z0-9]|[._]){5,19}$`
MoneyReg = `^(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*))$`
MobileReg = `^[1]([3-9])[0-9]{9}$`
)

133
merchant/sys/enum/status.go Normal file
View File

@@ -0,0 +1,133 @@
/***************************************************
** @Desc : This file for 状态常量
** @Time : 19.11.30 11:12
** @Author : Joker
** @File : status
** @Last Modified by : Joker
** @Last Modified time: 19.11.30 11:12
** @Software: GoLand
****************************************************/
package enum
// 成功与否
const (
FailedFlag = -9
FailedString = "操作失败! "
FailedToAdmin = "系统内部错误,请联系管理员!"
SuccessFlag = 9
SuccessString = "操作成功! "
)
// 用户状态
const (
ACTIVE = "active"
FREEZE = "FREEZE"
UNACTIVE = "unactive"
)
var userStatus = map[string]string{
ACTIVE: "激活",
FREEZE: "冻结",
UNACTIVE: "冻结",
}
// 用户状态
func GetUserStatus() map[string]string {
return userStatus
}
// 充值订单状态
const (
SUCCESS = "success"
FAILED = "failed"
WAITING_PAYMENT = "wait"
)
var orderStatus = map[string]string{
SUCCESS: "交易成功",
FAILED: "交易失败",
WAITING_PAYMENT: "等待支付",
}
// 充值订单状态
func GetOrderStatus() map[string]string {
return orderStatus
}
// 投诉订单状态
const (
YES = "yes"
NO = "no"
)
var orderComStatus = map[string]string{
YES: "冻结",
NO: "未冻结",
}
// 投诉订单状态
func GetComOrderStatus() map[string]string {
return orderComStatus
}
// 结算订单状态
const (
WAIT_CONFIRM = "payfor_confirm"
REMITTING = "payfor_solving"
REMIT_FAIL = "failed"
BANK_DEALING = "payfor_banking"
REMIT_SUCCESS = "success"
)
var settlementStatus = map[string]string{
WAIT_CONFIRM: "等待审核",
REMITTING: "打款中",
REMIT_FAIL: "打款失败",
BANK_DEALING: "银行处理中",
REMIT_SUCCESS: "打款成功",
}
// 结算订单状态
func GetSettlementStatus() map[string]string {
return settlementStatus
}
// 充值订单状态
const (
RECHARGE = "recharge"
REFUND = "refund"
FREEZER = "freeze"
UNFREEZE = "unfreeze"
)
var rechargeStatus = map[string]string{
RECHARGE: "充值",
REFUND: "退款",
FREEZER: "冻结",
UNFREEZE: "解冻",
}
// 充值订单状态
func GetRechargeStatus() map[string]string {
return rechargeStatus
}
// 历史记录状态
const (
PLUS_AMOUNT = "plus_amount"
SUB_AMOUNT = "sub_amount"
FREEZE_AMOUNT = "freeze_amount"
UNFREEZE_AMOUNT = "unfreeze_amount"
)
var historyStatus = map[string]string{
PLUS_AMOUNT: "加款",
SUB_AMOUNT: "减款",
FREEZE_AMOUNT: "冻结",
UNFREEZE_AMOUNT: "解冻",
}
// 历史记录状态
func GetHistoryStatus() map[string]string {
return historyStatus
}

View File

@@ -0,0 +1,150 @@
/***************************************************
** @Desc : This file for 共有方法
** @Time : 2019.04.01 11:48
** @Author : Joker
** @File : public_method
** @Last Modified by : Joker
** @Last Modified time: 2019-11-29 11:05:28
** @Software: GoLand
****************************************************/
package sys
import (
"fmt"
"math/rand"
"merchant/sys/enum"
"os"
"strconv"
"strings"
"time"
)
type PublicMethod struct{}
// 返回当前时间的字符串:2006-01-02 15:04:05
func (*PublicMethod) GetNowTime() string {
return time.Now().Format("2006-01-02 15:04:05")
}
// 返回当前时间的字符串:20060102150405
func (*PublicMethod) GetNowTimeV2() string {
return time.Now().Format("20060102150405")
}
// 返回格式化的字符串:2006-01-02 15:04:05
func (*PublicMethod) ParseDatetime(t time.Time) string {
f := t.Format("2006-01-02 15:04:05")
if strings.Compare("0001-01-01 00:00:00", f) == 0 {
f = ""
}
return f
}
// 比较是否是同一天
func (*PublicMethod) IsSameDay(d string) (bool, string) {
now := time.Now()
parse, e := time.Parse("2006-01-02 15:04:05", d)
if e != nil {
return false, fmt.Sprintf("比较时间:%s 格式不对, %v", d, e)
}
year := now.Year()-parse.Year() == 0
mouth := strings.Compare(now.Month().String(), parse.Month().String()) == 0
day := now.Day()-parse.Day() == 0
if year && mouth && day {
return true, ""
}
return false, fmt.Sprintf("比较时间:%s 与今天不是同一天,当天收益清零", d)
}
// 在数字、大写字母、小写字母范围内生成num位的随机字符串
func (*PublicMethod) RandomString(length int) string {
// 48 ~ 57 数字
// 65 ~ 90 A ~ Z
// 97 ~ 122 a ~ z
// 一共62个字符在0~61进行随机小于10时在数字范围随机
// 小于36在大写范围内随机其他在小写范围随机
rand.Seed(time.Now().UnixNano())
result := make([]string, 0, length)
for i := 0; i < length; i++ {
t := rand.Intn(62)
if t < 10 {
result = append(result, strconv.Itoa(rand.Intn(10)))
} else if t < 36 {
result = append(result, string(rand.Intn(26)+65))
} else {
result = append(result, string(rand.Intn(26)+97))
}
}
return strings.Join(result, "")
}
// 生成n位随机数字字符串
func (*PublicMethod) RandomIntOfString(length int) string {
result := make([]string, 0, length)
rand.Seed(time.Now().UnixNano())
for i := 0; i < length; i++ {
randInt := rand.Intn(10)
result = append(result, strconv.Itoa(randInt))
}
return strings.Join(result, "")
}
// @Description: 返回当前操作数据库的状态
// @Author: Joker
// @Date: 2019.04.01 14:37
// @Param: code: 状态码,msg; 状态信息:url: 跳转地址; data: json内容
// @return: Json串
func (*PublicMethod) JsonFormat(code int, data interface{}, msg string, url string) (json map[string]interface{}) {
if code == 9 {
json = map[string]interface{}{
"code": code,
"data": data,
"msg": msg,
"url": url,
}
} else {
json = map[string]interface{}{
"code": code,
"msg": msg,
"url": url,
}
}
return json
}
// 返回当前操作数据库的状态:成功/失败
func (*PublicMethod) GetDatabaseStatus(code int) map[string]interface{} {
msg := enum.FailedString
if code == enum.SuccessFlag {
msg = enum.SuccessString
}
out := make(map[string]interface{})
out["code"] = code
out["msg"] = msg
return out
}
// 格式化浮点数
func (*PublicMethod) FormatFloat64ToString(f float64) string {
if f < 0 {
f = 0
}
return fmt.Sprintf("%0.2f", f)
}
// 判断文件或文件夹是否存在
// 使用os.Stat()函数返回的错误值进行判断:
// 如果返回的错误为nil,说明文件或文件夹存在
// 如果返回的错误类型
// 使用os.IsNotExist()判断为true,说明文件或文件夹不存在
// 如果返回的错误为其它类型,则不确定是否在存在
func (*PublicMethod) PathExists(path string) (bool, error) {
_, err := os.Stat(path)
if err == nil {
return true, nil
}
if os.IsNotExist(err) {
return false, nil
}
return false, err
}

31
merchant/sys/session.go Normal file
View File

@@ -0,0 +1,31 @@
/***************************************************
** @Desc : This file for session配置
** @Time : 19.11.30 17:44
** @Author : Joker
** @File : session
** @Last Modified by : Joker
** @Last Modified time: 19.11.30 17:44
** @Software: GoLand
****************************************************/
package sys
import (
beego "github.com/beego/beego/v2/server/web"
"merchant/sys/enum"
)
func InitSession() {
// 开启session
beego.BConfig.WebConfig.Session.SessionOn = true
//beego.BConfig.WebConfig.Session.SessionProvider = "file"
beego.BConfig.WebConfig.Session.SessionName = enum.LocalSessionName
beego.BConfig.WebConfig.Session.SessionGCMaxLifetime = enum.SessionExpireTime
beego.BConfig.WebConfig.Session.SessionCookieLifeTime = enum.SessionExpireTime
//is, _ := pubMethod.PathExists(enum.SessionPath)
//if !is {
// _ = os.Mkdir(enum.SessionPath, os.ModePerm)
//}
beego.BConfig.WebConfig.Session.SessionProviderConfig = enum.SessionPath
}