|
- package mw
-
- import (
- "applet/app/comm/db"
- "applet/app/comm/e"
- "applet/app/comm/md"
- "applet/app/comm/svc"
- "applet/app/comm/utils"
- "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/rule/mw"
- "errors"
- "fmt"
- "github.com/gin-gonic/gin"
- "strconv"
- "strings"
- )
-
- // DB is 中间件 用来检查master_id是否有对应的数据库engine
- func DB(c *gin.Context) {
- fmt.Println(c.Request.Header)
- masterID := mw.GetMasterId(db.Db, c)
- _, ok := db.DBs[masterID]
- if !ok {
- e.OutErr(c, e.ERR_MASTER_ID, errors.New("not found master_id in DBs"))
- return
- }
-
- c.Set("mid", masterID)
- //判断是否有独立域名
- domain_wap_base := svc.GetWebSiteDomainInfo(c, "wap")
- httpStr := "http://"
- if c.GetHeader("Platform") == md.PLATFORM_WX_APPLET || c.GetHeader("Platform") == md.PLATFORM_ALIPAY_APPLET || c.GetHeader("Platform") == md.PLATFORM_BAIDU_APPLET || c.GetHeader("Platform") == md.PLATFORM_TOUTIAO_APPLET || c.GetHeader("Platform") == md.PLATFORM_TIKTOK_APPLET {
- httpStr = "https://"
- domain_wap_base = strings.Replace(domain_wap_base, "http://", httpStr, 1)
- }
- c.Set("domain_wap_base", domain_wap_base)
- c.Set("appUserDefaultAvatar", svc.SysCfgGet(c, "app_user_default_avatar"))
- c.Set("h5_api_secret_key", svc.SysCfgGet(c, "h5_api_secret_key"))
- c.Set("app_api_secret_key", svc.SysCfgGet(c, "app_api_secret_key"))
- c.Set("applet_api_secret_key", svc.SysCfgGet(c, "applet_api_secret_key"))
- c.Set("commission_prec", svc.SysCfgGet(c, "commission_prec"))
- areaCommissionPrec := svc.SysCfgGet(c, "area_commission_prec")
- if areaCommissionPrec == "" {
- areaCommissionPrec = "2"
- }
- c.Set("area_commission_prec", areaCommissionPrec)
- areaFanCommissionPrec := svc.SysCfgGet(c, "area_fan_commission_prec")
- if areaFanCommissionPrec == "" {
- areaFanCommissionPrec = "2"
- }
- c.Set("area_fan_commission_prec", areaFanCommissionPrec)
- c.Set("commission_prec", svc.SysCfgGet(c, "commission_prec"))
- c.Set("is_show_point", svc.SysCfgGet(c, "is_show_point"))
- c.Set("integral_prec", svc.SysCfgGet(c, "integral_prec"))
- translateOpen := ""
- if strings.Contains(c.GetHeader("locale"), "zh_Hant_") {
- translateOpen = "zh_Hant_"
- }
- if strings.Contains(c.GetHeader("locale"), "ug_CN") {
- translateOpen = "ug_CN"
- }
- //总开关
- canTransferMaster := db.SysCfgGet(c, "virtual_coin_can_transfer")
- if canTransferMaster == "" {
- canTransferMaster = "0"
- }
- canBackOutMaster := db.SysCfgGet(c, "virtual_coin_can_backout")
- if canBackOutMaster == "" {
- canBackOutMaster = "0"
- }
- c.Set("virtual_coin_can_transfer", canTransferMaster)
- c.Set("virtual_coin_can_backout", canBackOutMaster)
- lvList := db.UserLevelAllMap(svc.MasterDb(c))
- c.Set("lv_list", utils.SerializeStr(lvList))
- c.Set("translate_open", translateOpen)
- smsType := svc.SysCfgGet(c, "sms_type")
- c.Set("sms_type", smsType)
- c.Next()
- }
-
- func isNumeric(str string) bool {
- _, err := strconv.ParseFloat(str, 64)
- return err == nil
- }
|