Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
杨树贤
/
go_supplier_sever
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
5489057a
authored
Sep 02, 2024
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
统计最后一次下单时间
parent
9c80c3b7
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
82 additions
and
4 deletions
app/common/config/mysql.go
app/dao/order.go
app/model/supplier.go
app/service/supplier_sku_statistics.go
config/dev/db.toml
app/common/config/mysql.go
View file @
5489057a
...
@@ -18,7 +18,7 @@ type GroupDatabase struct {
...
@@ -18,7 +18,7 @@ type GroupDatabase struct {
Prefix
string
Prefix
string
}
}
//单数据库配置
//
单数据库配置
func
BuildDatabaseList
()
(
DatabaseList
map
[
string
]
BaseDatabase
)
{
func
BuildDatabaseList
()
(
DatabaseList
map
[
string
]
BaseDatabase
)
{
return
map
[
string
]
BaseDatabase
{
return
map
[
string
]
BaseDatabase
{
"micro"
:
{
"micro"
:
{
...
@@ -33,12 +33,17 @@ func BuildDatabaseList() (DatabaseList map[string]BaseDatabase) {
...
@@ -33,12 +33,17 @@ func BuildDatabaseList() (DatabaseList map[string]BaseDatabase) {
MaxIdleCons
:
lib
.
Instance
(
"db"
)
.
GetInt
(
"supplier.max_idle_conn"
),
MaxIdleCons
:
lib
.
Instance
(
"db"
)
.
GetInt
(
"supplier.max_idle_conn"
),
MaxOpenCons
:
lib
.
Instance
(
"db"
)
.
GetInt
(
"supplier.max_open_conn"
),
MaxOpenCons
:
lib
.
Instance
(
"db"
)
.
GetInt
(
"supplier.max_open_conn"
),
},
},
"purchase"
:
{
DataSourceName
:
lib
.
Instance
(
"db"
)
.
GetString
(
"purchase.data_source_name"
),
Prefix
:
lib
.
Instance
(
"db"
)
.
GetString
(
"purchase.table_prefix"
),
MaxIdleCons
:
lib
.
Instance
(
"db"
)
.
GetInt
(
"purchase.max_idle_conn"
),
MaxOpenCons
:
lib
.
Instance
(
"db"
)
.
GetInt
(
"purchase.max_open_conn"
),
},
}
}
}
}
//主从mysql数据库配置
//
主从mysql数据库配置
func
BuildGroupDatabaseList
()
(
DatabaseList
map
[
string
]
GroupDatabase
)
{
func
BuildGroupDatabaseList
()
(
DatabaseList
map
[
string
]
GroupDatabase
)
{
return
map
[
string
]
GroupDatabase
{
return
map
[
string
]
GroupDatabase
{}
}
}
}
app/dao/order.go
0 → 100644
View file @
5489057a
package
dao
import
(
"fmt"
"go_supplier_sever/app/model"
)
// 获取每个供应商最后一次做单时间
func
StatisticsSupplierLastOrderTime
()
(
err
error
)
{
fmt
.
Println
(
"开始统计供应商最后一次订单时间"
)
supplier
:=
new
(
model
.
Supplier
)
//先去根据供应商内部编码找出对应的supplierId
rows
,
err
:=
Dao
.
GetDb
(
"supplier"
)
.
Table
(
"lie_supplier_channel"
)
.
Where
(
"is_type = ?"
,
0
)
.
OrderBy
(
"supplier_id desc"
)
.
Rows
(
supplier
)
if
err
!=
nil
{
return
err
}
defer
rows
.
Close
()
for
rows
.
Next
()
{
err
=
rows
.
Scan
(
supplier
)
//记录最后一次订单时间
var
lastOrderTime
int
err
=
UpdateSupplierLastOrderTime
(
supplier
.
SupplierId
,
lastOrderTime
)
if
err
!=
nil
{
return
err
}
}
fmt
.
Println
(
"执行完成历史有订单的供应"
)
return
}
type
PurchaseOrder
struct
{
PurchaseId
int
`json:"purchase_id"`
SupplierId
int
`json:"supplier_id"`
CreateTime
int
`json:"create_time"`
}
func
UpdateSupplierLastOrderTime
(
supplierId
int
,
lastOrderTime
int
)
(
err
error
)
{
var
purchaseOrder
PurchaseOrder
supplier
:=
new
(
model
.
Supplier
)
//先去根据供应商内部编码找出对应的supplierId
_
,
err
=
Dao
.
GetDb
(
"purchase"
)
.
Table
(
"lie_purchase_order"
)
.
Where
(
"supplier_id = ?"
,
supplierId
)
.
OrderBy
(
"purchase_id desc"
)
.
Get
(
&
purchaseOrder
)
if
purchaseOrder
.
SupplierId
==
0
{
lastOrderTime
=
0
}
if
err
!=
nil
{
return
err
}
//fmt.Println(purchaseOrder)
supplier
.
LastOrderTime
=
purchaseOrder
.
CreateTime
_
,
err
=
Dao
.
GetDb
(
"supplier"
)
.
Table
(
"lie_supplier_channel"
)
.
Where
(
"supplier_id = ?"
,
supplierId
)
.
MustCols
(
"last_order_time"
)
.
Update
(
supplier
)
if
err
!=
nil
{
return
err
}
return
}
app/model/supplier.go
View file @
5489057a
...
@@ -11,4 +11,5 @@ type Supplier struct {
...
@@ -11,4 +11,5 @@ type Supplier struct {
CreateTime
int64
CreateTime
int64
SkuCreateTime
int
SkuCreateTime
int
SkuUpdateTime
int
SkuUpdateTime
int
LastOrderTime
int
}
}
app/service/supplier_sku_statistics.go
View file @
5489057a
...
@@ -7,6 +7,13 @@ import (
...
@@ -7,6 +7,13 @@ import (
func
StatisticsSupplierSkuStatus
()
(
err
error
)
{
func
StatisticsSupplierSkuStatus
()
(
err
error
)
{
fmt
.
Println
(
"开始统计"
)
fmt
.
Println
(
"开始统计"
)
err
=
dao
.
StatisticsSupplierLastOrderTime
()
if
err
!=
nil
{
return
err
}
//return
err
=
dao
.
StatisticsSkuCreateTime
()
err
=
dao
.
StatisticsSkuCreateTime
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
...
config/dev/db.toml
View file @
5489057a
...
@@ -29,3 +29,9 @@ ShowSQL = false
...
@@ -29,3 +29,9 @@ ShowSQL = false
max_idle_conn
=
10
max_idle_conn
=
10
table_prefix
=
""
table_prefix
=
""
max_conn_life_time
=
100
max_conn_life_time
=
100
[purchase]
data_source_name
=
"liexin_purchase:liexin_purchase#zsyM@tcp(192.168.1.238:3306)/liexin_purchase?charset=utf8&parseTime=true&loc=Asia%2FChongqing"
max_open_conn
=
20
max_idle_conn
=
10
table_prefix
=
"lie_"
max_conn_life_time
=
100
\ No newline at end of file
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