Files
jx-callback/globals/globals.go
suyl 51e559a032 a
2021-05-21 16:41:53 +08:00

170 lines
5.7 KiB
Go

package globals
import (
"git.rosy.net.cn/baseapi"
"github.com/astaxie/beego/core/logs"
"github.com/astaxie/beego/server/web"
_ "github.com/go-sql-driver/mysql" // import your used driver
"go.uber.org/zap"
)
var (
ReallyCallPlatformAPI bool
ReallySendWeixinMsg bool
SugarLogger *zap.SugaredLogger
AliKey string
AliSecret string
EnableStoreWrite bool
EnableJdStoreWrite bool
EnableEbaiStoreWrite bool
EnableElmStoreWrite bool
EnableMtwmStoreWrite bool
EnableWscStoreWrite bool
EnablePendingChange bool
EnableYbStoreWrite bool
EnableJdShopWrite bool //京东商城
QiniuBucket string
WeimobCallbackURL string
WeimobStateSecret string
BackstageHost string
WxBackstageHost string
GetWeixinTokenURL string
GetWeixin2TokenURL string
GetWeixinTokenKey string
GetYLYTokenURL string
GetPushTokenURL string
GetWeimobTokenURL string
StoreName string
StoreNameMtwm string
StoreNameEbai string
StoreNameEbai2 string
SMSSignName string
SMSMobileVerifyTemplate string
SMSNewOrderTemplate string
SMSNewOrderTemplateQ string
SMSOrderCanceledTemplate string
SMSNewUserOrderTemplate string
SMSJxOrderDelivering string
EnableWXAuth2 bool
DisableWXAuth1 bool
WxpayNotifyURL string
TLPayNotifyURL string
FnNotifyURL string
JdOrgCode string
Jd2OrgCode string
Jd3OrgCode string
JdcsOrgCode string
JdydOrgCode string
JdLoginName string
MtwmCode string
Mtwm2Code string
IsStoreSkuAct bool
IsAddEvent bool
OutputDebugMsgLevel int
)
func init() {
logs.SetLogFuncCallDepth(3)
web.BConfig.Log.AccessLogs = true
logger, _ := zap.NewDevelopment()
SugarLogger = logger.Sugar()
baseapi.Init(SugarLogger)
Init() // 这里必须要自动调用,不然直接引用全局变量的模块得不到正确的配置值
}
func Init() {
if false { //!IsProductEnv() {
OutputDebugMsgLevel = 1
}
SugarLogger.Infof("globals RunMode=%s", web.BConfig.RunMode)
ReallyCallPlatformAPI = (web.BConfig.RunMode != "dev" && web.BConfig.RunMode != "test")
ReallySendWeixinMsg = ReallyCallPlatformAPI && IsProductEnv()
AliKey = web.AppConfig.DefaultString("aliKey", "")
AliSecret = web.AppConfig.DefaultString("aliSecret", "")
EnableStoreWrite = web.AppConfig.DefaultBool("enableStoreWrite", false)
EnableJdStoreWrite = EnableStoreWrite && web.AppConfig.DefaultBool("enableJdStoreWrite", false)
EnableEbaiStoreWrite = EnableStoreWrite && web.AppConfig.DefaultBool("enableEbaiStoreWrite", false)
EnableElmStoreWrite = EnableStoreWrite && web.AppConfig.DefaultBool("enableElmStoreWrite", false)
EnableMtwmStoreWrite = EnableStoreWrite && web.AppConfig.DefaultBool("enableMtwmStoreWrite", false)
EnableWscStoreWrite = EnableStoreWrite && web.AppConfig.DefaultBool("enableWscStoreWrite", false)
// EnablePendingChange = web.AppConfig.DefaultBool("enablePendingChange", false)
EnableYbStoreWrite = EnableStoreWrite && web.AppConfig.DefaultBool("enableYbStoreWrite", false)
EnableJdShopWrite = EnableStoreWrite && web.AppConfig.DefaultBool("enableJdShopWrite", false)
QiniuBucket = web.AppConfig.DefaultString("qiniuBucket", "")
WeimobCallbackURL = web.AppConfig.DefaultString("weimobCallbackURL", "")
WeimobStateSecret = web.AppConfig.DefaultString("weimobStateSecret", "")
BackstageHost = web.AppConfig.DefaultString("backstageHost", "")
WxBackstageHost = web.AppConfig.DefaultString("wxBackstageHost", "")
GetWeixinTokenURL = web.AppConfig.DefaultString("getWeixinTokenURL", "")
GetWeixin2TokenURL = web.AppConfig.DefaultString("getWeixin2TokenURL", "")
GetYLYTokenURL = web.AppConfig.DefaultString("getYLYTokenURL", "")
GetWeimobTokenURL = web.AppConfig.DefaultString("getWeimobTokenURL", "")
GetWeixinTokenKey = web.AppConfig.DefaultString("getWeixinTokenKey", "")
GetPushTokenURL = web.AppConfig.DefaultString("getPushTokenURL", "")
StoreName = web.AppConfig.DefaultString("storeName", "")
StoreNameMtwm = web.AppConfig.DefaultString("storeNameMtwm", "")
StoreNameEbai = web.AppConfig.DefaultString("storeNameEbai", "")
StoreNameEbai2 = web.AppConfig.DefaultString("storeNameEbai2", "")
SMSSignName = web.AppConfig.DefaultString("smsSignName", "")
SMSMobileVerifyTemplate = web.AppConfig.DefaultString("smsMobileVerifyTemplate", "")
SMSNewOrderTemplate = web.AppConfig.DefaultString("smsNewOrderTemplate", "")
SMSNewOrderTemplateQ = web.AppConfig.DefaultString("smsNewOrderTemplateQ", "")
SMSOrderCanceledTemplate = web.AppConfig.DefaultString("smsOrderCanceledTemplate", "")
SMSNewUserOrderTemplate = web.AppConfig.DefaultString("smsNewUserOrderTemplate", "")
SMSJxOrderDelivering = web.AppConfig.DefaultString("smsJxOrderDelivering", "")
EnableWXAuth2 = true // web.BConfig.RunMode == "beta"
DisableWXAuth1 = true
WxpayNotifyURL = web.AppConfig.DefaultString("wxpayNotifyURL", "")
TLPayNotifyURL = web.AppConfig.DefaultString("tonglianPayNotifyURL", "")
FnNotifyURL = web.AppConfig.DefaultString("fnCallbackURL", "")
JdOrgCode = web.AppConfig.DefaultString("jdOrgCode", "")
Jd2OrgCode = web.AppConfig.DefaultString("jd2OrgCode", "")
Jd3OrgCode = web.AppConfig.DefaultString("jd3OrgCode", "")
JdcsOrgCode = web.AppConfig.DefaultString("jdcsOrgCode", "")
JdydOrgCode = web.AppConfig.DefaultString("jdydOrgCode", "")
JdLoginName = web.AppConfig.DefaultString("jdLoginName", "")
IsAddEvent = web.AppConfig.DefaultBool("addEvent", false)
IsStoreSkuAct = !IsProductEnv()
MtwmCode = web.AppConfig.DefaultString("mtwmAppID", "")
Mtwm2Code = web.AppConfig.DefaultString("mtwmAppID2", "")
}
func IsCallbackAlwaysReturnSuccess() bool {
return web.BConfig.RunMode == "beta"
}
func IsMainProductEnv() bool {
return web.BConfig.RunMode == "prod"
}
func IsProductEnv() bool {
return IsMainProductEnv() || web.BConfig.RunMode == "jxgy"
}