Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
黄成意
/
go_sku_server
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
46efb559
authored
Jan 25, 2021
by
mushishixian
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
添加是否允许后天下单
parent
edf4de5c
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
32 additions
and
34 deletions
boot/app.go
cmd/http_server.go
model/activity.go
model/ly_sku.go
pkg/logger/logger.go
service/service_activity.go
service/service_zy_common.go
boot/app.go
View file @
46efb559
...
@@ -24,6 +24,6 @@ func Boot(configPath string) (err error) {
...
@@ -24,6 +24,6 @@ func Boot(configPath string) (err error) {
panic
(
err
)
panic
(
err
)
return
return
}
}
logger
.
Log
i
nit
()
logger
.
Log
I
nit
()
return
return
}
}
cmd/http_server.go
View file @
46efb559
...
@@ -3,6 +3,7 @@ package main
...
@@ -3,6 +3,7 @@ package main
import
(
import
(
"flag"
"flag"
"github.com/gin-gonic/gin"
"github.com/gin-gonic/gin"
logger
"github.com/ichunt2019/log"
"github.com/micro/go-micro/v2/web"
"github.com/micro/go-micro/v2/web"
"go_sku_server/boot"
"go_sku_server/boot"
"go_sku_server/pkg/config"
"go_sku_server/pkg/config"
...
...
model/activity.go
View file @
46efb559
...
@@ -6,6 +6,7 @@ type Activity struct {
...
@@ -6,6 +6,7 @@ type Activity struct {
SupplierIdList
[]
string
SupplierIdList
[]
string
SupplierType
int
`json:"supplier_type"`
SupplierType
int
`json:"supplier_type"`
UserScope
int
`json:"user_scope"`
UserScope
int
`json:"user_scope"`
CanAdminOrder
int
`json:"can_admin_order"`
SignText
string
`json:"sign_text"`
SignText
string
`json:"sign_text"`
BrandIds
string
`json:"brand_ids"`
BrandIds
string
`json:"brand_ids"`
BrandIdList
[]
string
BrandIdList
[]
string
...
...
model/ly_sku.go
View file @
46efb559
...
@@ -77,7 +77,8 @@ type PriceActivity struct {
...
@@ -77,7 +77,8 @@ type PriceActivity struct {
type
GiftActivity
struct
{
type
GiftActivity
struct
{
ActivityCommon
ActivityCommon
ItemList
[]
ActivityItem
`json:"items,omitempty"`
CanAdminOrder
int
`json:"can_admin_order,omitempty"`
ItemList
[]
ActivityItem
`json:"items,omitempty"`
}
}
type
ActivityCommon
struct
{
type
ActivityCommon
struct
{
...
...
pkg/logger/logger.go
View file @
46efb559
...
@@ -21,34 +21,33 @@ var (
...
@@ -21,34 +21,33 @@ var (
logD
map
[
string
]
logger
.
LogInterface
logD
map
[
string
]
logger
.
LogInterface
)
)
var
once
sync
.
Once
var
once
sync
.
Once
func
Loginit
()
{
func
LogInit
()
{
once
.
Do
(
func
()
{
once
.
Do
(
func
()
{
fmt
.
Print
(
"日志初始化开始"
)
fmt
.
Print
(
"日志初始化开始"
)
configs
:=
config
.
GetSectionValues
(
"log_config"
)
configs
:=
config
.
GetSectionValues
(
"log_config"
)
logD
=
make
(
map
[
string
]
logger
.
LogInterface
)
logD
=
make
(
map
[
string
]
logger
.
LogInterface
)
for
_
,
configOne
:=
range
configs
{
for
_
,
configOne
:=
range
configs
{
sliceConfig
:=
strings
.
Split
(
configOne
,
","
)
sliceConfig
:=
strings
.
Split
(
configOne
,
","
)
log
:=
getLog
(
sliceConfig
[
0
],
sliceConfig
[
1
],
"0"
)
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 path 路径 比如sku_save 即文件夹是 sku 文件名类似 是save_2020-12-10.log
@param msg 错误文本
@param msg 错误文本
@Level 默认是 logger.LogLevelInfo
@Level 默认是 logger.LogLevelInfo
示例
示例
*/
*/
func
SyncInsert
(
path
string
,
msg
string
,
Levels
...
int
)
{
func
SyncInsert
(
path
string
,
msg
string
,
Levels
...
int
)
{
log
:=
getLog
(
path
,
"10"
,
"1"
)
log
:=
getLog
(
path
,
"10"
,
"1"
)
level
:=
LogLevelInfo
level
:=
LogLevelInfo
if
(
len
(
Levels
)
>
0
)
{
if
len
(
Levels
)
>
0
{
level
=
Levels
[
0
]
level
=
Levels
[
0
]
}
}
switch
level
{
switch
level
{
case
LogLevelDebug
:
case
LogLevelDebug
:
...
@@ -72,32 +71,32 @@ func SyncInsert(path string,msg string,Levels ...int) {
...
@@ -72,32 +71,32 @@ func SyncInsert(path string,msg string,Levels ...int) {
//入口
//入口
func
Select
(
logFiled
string
)
logger
.
LogInterface
{
func
Select
(
logFiled
string
)
logger
.
LogInterface
{
log
,
ok
:=
logD
[
logFiled
]
log
,
ok
:=
logD
[
logFiled
]
if
(
!
ok
)
{
if
!
ok
{
panic
(
"log配置:"
+
logFiled
+
"不存在"
)
panic
(
"log配置:"
+
logFiled
+
"不存在"
)
}
}
if
log
,
ok
:=
log
.
(
logger
.
LogInterface
);
ok
{
if
log
,
ok
:=
log
.
(
logger
.
LogInterface
);
ok
{
return
log
return
log
}
}
panic
(
"type not logger.LogInterface"
)
panic
(
"type not logger.LogInterface"
)
}
}
//内部方法,获取log
//内部方法,获取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
:=
make
(
map
[
string
]
string
)
logConfig
[
"log_chan_size"
]
=
"10"
logConfig
[
"log_chan_size"
]
=
"10"
slicePath
:=
strings
.
Split
(
path
,
"_"
)
slicePath
:=
strings
.
Split
(
path
,
"_"
)
if
(
slicePath
[
0
]
==
""
||
slicePath
[
1
]
==
""
)
{
if
slicePath
[
0
]
==
""
||
slicePath
[
1
]
==
""
{
panic
(
"配置文件出错:文件/路径配置出错;提示:第一个参数格式应为A_B"
)
panic
(
"配置文件出错:文件/路径配置出错;提示:第一个参数格式应为A_B"
)
}
}
logConfig
[
"log_path"
]
=
"logs/"
+
slicePath
[
0
]
logConfig
[
"log_path"
]
=
"logs/"
+
slicePath
[
0
]
logConfig
[
"log_name"
]
=
slicePath
[
1
]
logConfig
[
"log_name"
]
=
slicePath
[
1
]
if
(
openSync
==
"1"
)
{
if
openSync
==
"1"
{
logConfig
[
"open_sync"
]
=
"1"
logConfig
[
"open_sync"
]
=
"1"
}
}
if
(
chan_size
!=
""
)
{
if
chan_size
!=
""
{
logConfig
[
"log_chan_size"
]
=
chan_size
logConfig
[
"log_chan_size"
]
=
chan_size
}
}
log
,
err
:=
logger
.
InitLogger
(
"file"
,
logConfig
)
log
,
err
:=
logger
.
InitLogger
(
"file"
,
logConfig
)
if
err
!=
nil
{
if
err
!=
nil
{
panic
(
"初始化log包出错:"
)
panic
(
"初始化log包出错:"
)
}
}
...
@@ -116,5 +115,3 @@ func SetUp() (err error) {
...
@@ -116,5 +115,3 @@ func SetUp() (err error) {
logger
.
Init
()
logger
.
Init
()
return
return
}
}
service/service_activity.go
View file @
46efb559
...
@@ -98,6 +98,7 @@ func (as *ActivityService) GetGiftActivity(checkData model.ActivityCheckData, ac
...
@@ -98,6 +98,7 @@ func (as *ActivityService) GetGiftActivity(checkData model.ActivityCheckData, ac
giftActivity
.
ActivityName
=
activity
.
ActivityName
giftActivity
.
ActivityName
=
activity
.
ActivityName
giftActivity
.
ActivityId
=
activity
.
ActivityId
giftActivity
.
ActivityId
=
activity
.
ActivityId
giftActivity
=
model
.
GiftActivity
{
giftActivity
=
model
.
GiftActivity
{
CanAdminOrder
:
activity
.
CanAdminOrder
,
ItemList
:
activity
.
ItemList
,
ItemList
:
activity
.
ItemList
,
ActivityCommon
:
model
.
ActivityCommon
{
ActivityCommon
:
model
.
ActivityCommon
{
HasActivity
:
hasActivity
,
HasActivity
:
hasActivity
,
...
...
service/service_zy_common.go
View file @
46efb559
package
service
package
service
import
(
import
(
"fmt"
"github.com/gin-gonic/gin"
"github.com/gin-gonic/gin"
"github.com/gomodule/redigo/redis"
"github.com/gomodule/redigo/redis"
"github.com/iancoleman/orderedmap"
"github.com/iancoleman/orderedmap"
...
@@ -100,8 +99,6 @@ func (qs *ZiyingService) HDActivityPrice(SkuInfo string) *orderedmap.OrderedMap
...
@@ -100,8 +99,6 @@ func (qs *ZiyingService) HDActivityPrice(SkuInfo string) *orderedmap.OrderedMap
A
.
Set
(
"has_gift_activity"
,
1
)
A
.
Set
(
"has_gift_activity"
,
1
)
A
.
Set
(
"gift_activity"
,
giftActivity
)
A
.
Set
(
"gift_activity"
,
giftActivity
)
}
}
fmt
.
Println
(
priceActivity
.
AllowCoupon
)
fmt
.
Println
(
giftActivity
.
AllowCoupon
)
//其中一类活动不允许优惠券,这个商品就不允许使用优惠券
//其中一类活动不允许优惠券,这个商品就不允许使用优惠券
var
allowCoupon
int
var
allowCoupon
int
if
priceActivity
.
HasActivity
&&
priceActivity
.
AllowCoupon
==
2
{
if
priceActivity
.
HasActivity
&&
priceActivity
.
AllowCoupon
==
2
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment