Commit 46efb559 by mushishixian

添加是否允许后天下单

parent edf4de5c
......@@ -24,6 +24,6 @@ func Boot(configPath string) (err error) {
panic(err)
return
}
logger.Loginit()
logger.LogInit()
return
}
......@@ -3,6 +3,7 @@ package main
import (
"flag"
"github.com/gin-gonic/gin"
logger "github.com/ichunt2019/log"
"github.com/micro/go-micro/v2/web"
"go_sku_server/boot"
"go_sku_server/pkg/config"
......
......@@ -6,6 +6,7 @@ type Activity struct {
SupplierIdList []string
SupplierType int `json:"supplier_type"`
UserScope int `json:"user_scope"`
CanAdminOrder int `json:"can_admin_order"`
SignText string `json:"sign_text"`
BrandIds string `json:"brand_ids"`
BrandIdList []string
......
......@@ -77,7 +77,8 @@ type PriceActivity struct {
type GiftActivity struct {
ActivityCommon
ItemList []ActivityItem `json:"items,omitempty"`
CanAdminOrder int `json:"can_admin_order,omitempty"`
ItemList []ActivityItem `json:"items,omitempty"`
}
type ActivityCommon struct {
......
......@@ -21,34 +21,33 @@ var (
logD map[string]logger.LogInterface
)
var once sync.Once
func Loginit() {
func LogInit() {
once.Do(func() {
fmt.Print("日志初始化开始")
configs:=config.GetSectionValues("log_config")
logD=make(map[string]logger.LogInterface)
for _,configOne:=range configs{
sliceConfig:=strings.Split(configOne, ",")
log:=getLog(sliceConfig[0],sliceConfig[1],"0")
configs := config.GetSectionValues("log_config")
logD = make(map[string]logger.LogInterface)
for _, configOne := range configs {
sliceConfig := strings.Split(configOne, ",")
log := getLog(sliceConfig[0], sliceConfig[1], "0")
logD[sliceConfig[0]]=log
logD[sliceConfig[0]] = log
}
})
}
/**
@param path 路径 比如sku_save 即文件夹是 sku 文件名类似 是save_2020-12-10.log
@param msg 错误文本
@Level 默认是 logger.LogLevelInfo
示例
*/
func SyncInsert(path string,msg string,Levels ...int) {
*/
func SyncInsert(path string, msg string, Levels ...int) {
log:=getLog(path,"10","1")
level:=LogLevelInfo
if(len(Levels)>0){
level=Levels[0]
log := getLog(path, "10", "1")
level := LogLevelInfo
if len(Levels) > 0 {
level = Levels[0]
}
switch level {
case LogLevelDebug:
......@@ -72,32 +71,32 @@ func SyncInsert(path string,msg string,Levels ...int) {
//入口
func Select(logFiled string) logger.LogInterface {
log, ok := logD[logFiled]
if(!ok){
panic("log配置:"+logFiled+"不存在")
if !ok {
panic("log配置:" + logFiled + "不存在")
}
if log,ok:=log.(logger.LogInterface);ok{
if log, ok := log.(logger.LogInterface); ok {
return log
}
panic("type not logger.LogInterface")
}
//内部方法,获取log
func getLog(path string,chan_size string,openSync string) logger.LogInterface {
func getLog(path string, chan_size string, openSync string) logger.LogInterface {
logConfig := make(map[string]string)
logConfig["log_chan_size"]="10"
slicePath:=strings.Split(path, "_")
if(slicePath[0]=="" || slicePath[1]==""){
logConfig["log_chan_size"] = "10"
slicePath := strings.Split(path, "_")
if slicePath[0] == "" || slicePath[1] == "" {
panic("配置文件出错:文件/路径配置出错;提示:第一个参数格式应为A_B")
}
logConfig["log_path"] = "logs/"+slicePath[0]
logConfig["log_path"] = "logs/" + slicePath[0]
logConfig["log_name"] = slicePath[1]
if(openSync=="1"){
if openSync == "1" {
logConfig["open_sync"] = "1"
}
if(chan_size!=""){
logConfig["log_chan_size"]=chan_size
if chan_size != "" {
logConfig["log_chan_size"] = chan_size
}
log,err:= logger.InitLogger("file", logConfig)
log, err := logger.InitLogger("file", logConfig)
if err != nil {
panic("初始化log包出错:")
}
......@@ -116,5 +115,3 @@ func SetUp() (err error) {
logger.Init()
return
}
......@@ -98,6 +98,7 @@ func (as *ActivityService) GetGiftActivity(checkData model.ActivityCheckData, ac
giftActivity.ActivityName = activity.ActivityName
giftActivity.ActivityId = activity.ActivityId
giftActivity = model.GiftActivity{
CanAdminOrder: activity.CanAdminOrder,
ItemList: activity.ItemList,
ActivityCommon: model.ActivityCommon{
HasActivity: hasActivity,
......
package service
import (
"fmt"
"github.com/gin-gonic/gin"
"github.com/gomodule/redigo/redis"
"github.com/iancoleman/orderedmap"
......@@ -100,8 +99,6 @@ func (qs *ZiyingService) HDActivityPrice(SkuInfo string) *orderedmap.OrderedMap
A.Set("has_gift_activity", 1)
A.Set("gift_activity", giftActivity)
}
fmt.Println(priceActivity.AllowCoupon)
fmt.Println(giftActivity.AllowCoupon)
//其中一类活动不允许优惠券,这个商品就不允许使用优惠券
var allowCoupon int
if priceActivity.HasActivity && priceActivity.AllowCoupon == 2 {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment