Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
孙龙
/
golang-queue-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
1e9e5713
authored
Dec 02, 2021
by
朱继来
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
调整竞调订单
parent
c6ea3408
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
6 deletions
dal/order/OrderItemsExt/OrderItemsExt.go
order/jingdiao/handle/handle.go
order/jingdiao/main.go
dal/order/OrderItemsExt/OrderItemsExt.go
0 → 100644
View file @
1e9e5713
package
OrderItemsExt
type
OrderItemsExt
struct
{
RecId
int
`db:"rec_id"`
Batch
string
`db:"batch"`
}
order/jingdiao/handle/handle.go
View file @
1e9e5713
...
...
@@ -66,7 +66,7 @@ func GetOneOrderItem() OrderItems.OrderItems {
var
order_item
OrderItems
.
OrderItems
var
field
string
=
"rec_id,goods_id,supplier_id,brand_id,standard_brand_id,goods_sn,goods_name,sku_name,supplier_name,brand_name,standard_brand_name,goods_type,"
+
"self_supplier_type,goods_number,goods_price,delivery_time,sale_type,ac_type,order_goods_type,buyer_id
,batch
"
"self_supplier_type,goods_number,goods_price,delivery_time,sale_type,ac_type,order_goods_type,buyer_id"
db
.
OrderDB
.
Get
(
&
order_item
,
"select "
+
field
+
" from lie_order_items as a join (select round( rand() * (select max(rec_id) from lie_order_items)) as brec_id) as b "
+
"on a.rec_id > b.brec_id and a.goods_price > 0.1 LIMIT 1"
)
...
...
order/jingdiao/main.go
View file @
1e9e5713
...
...
@@ -8,6 +8,7 @@ import (
"go-queue-server/dal/order/JingdiaoAddress"
"go-queue-server/dal/order/Order"
"go-queue-server/dal/order/OrderItems"
"go-queue-server/dal/order/OrderItemsExt"
_
"go-queue-server/dal/order/OtherAddress"
"go-queue-server/order/jingdiao/handle"
"go-queue-server/util"
...
...
@@ -136,6 +137,7 @@ func CreateOrder(create_time int64) {
// 订单数据
order
:=
make
(
map
[
string
]
interface
{},
0
)
goods_data
:=
make
(
map
[
string
]
interface
{},
0
)
//goods_ext_data := make(map[string]interface{}, 0)
order
[
"order_sn"
]
=
order_sn
order
[
"user_id"
]
=
user_id
...
...
@@ -165,10 +167,13 @@ func CreateOrder(create_time int64) {
goods_data
[
"ac_type"
]
=
order_item
.
AcType
goods_data
[
"order_goods_type"
]
=
order_item
.
OrderGoodsType
goods_data
[
"buyer_id"
]
=
order_item
.
BuyerId
goods_data
[
"batch"
]
=
order_item
.
Batch
var
item_ext
OrderItemsExt
.
OrderItemsExt
db
.
OrderDB
.
Get
(
&
item_ext
,
"select rec_id, batch from lie_order_items_ext where rec_id = ?"
,
order_item
.
RecId
)
conn
,
err
:=
db
.
OrderDB
.
Begin
()
// 开启事务
if
err
!=
nil
{
logger
.
Info
(
"开启事务失败,原因:"
+
err
.
Error
())
return
}
...
...
@@ -178,6 +183,7 @@ func CreateOrder(create_time int64) {
LastInsertId
,
err
:=
res
.
LastInsertId
()
if
err
!=
nil
{
logger
.
Info
(
"新增订单表失败,原因:"
+
err
.
Error
())
conn
.
Rollback
()
//回滚
return
}
...
...
@@ -188,18 +194,29 @@ func CreateOrder(create_time int64) {
// 添加lie_order_extend
_
,
err
=
conn
.
Exec
(
"insert into lie_order_extend (order_id, is_manager_audit) values (?, ?)"
,
order_id
,
3
)
if
err
!=
nil
{
logger
.
Info
(
"新增订单扩展表失败,原因:"
+
err
.
Error
())
conn
.
Rollback
()
//回滚
return
}
// 添加lie_order_items
_
,
err
=
conn
.
Exec
(
"insert into lie_order_items (order_id, user_id, goods_id, supplier_id, brand_id, standard_brand_id, goods_sn, goods_name, sku_name, supplier_name, brand_name, "
+
"standard_brand_name, goods_type, self_supplier_type, goods_number, goods_price, delivery_time, sale_type, ac_type, order_goods_type, buyer_id,
batch,
single_pre_price) values (?, ?, ?, ?, "
+
"?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?
, ?
)"
,
order_id
,
goods_data
[
"user_id"
],
goods_data
[
"goods_id"
],
goods_data
[
"supplier_id"
],
relt
,
err
:
=
conn
.
Exec
(
"insert into lie_order_items (order_id, user_id, goods_id, supplier_id, brand_id, standard_brand_id, goods_sn, goods_name, sku_name, supplier_name, brand_name, "
+
"standard_brand_name, goods_type, self_supplier_type, goods_number, goods_price, delivery_time, sale_type, ac_type, order_goods_type, buyer_id, single_pre_price) values (?, ?, ?, ?, "
+
"?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
,
order_id
,
goods_data
[
"user_id"
],
goods_data
[
"goods_id"
],
goods_data
[
"supplier_id"
],
goods_data
[
"brand_id"
],
goods_data
[
"standard_brand_id"
],
goods_data
[
"goods_sn"
],
goods_data
[
"goods_name"
],
goods_data
[
"sku_name"
],
goods_data
[
"supplier_name"
],
goods_data
[
"brand_name"
],
goods_data
[
"standard_brand_name"
],
goods_data
[
"goods_type"
],
goods_data
[
"self_supplier_type"
],
goods_data
[
"goods_number"
],
goods_data
[
"goods_price"
],
goods_data
[
"delivery_time"
],
goods_data
[
"sale_type"
],
goods_data
[
"ac_type"
],
goods_data
[
"order_goods_type"
],
goods_data
[
"buyer_id"
],
goods_data
[
"batch"
],
goods_data
[
"goods_price"
])
goods_data
[
"delivery_time"
],
goods_data
[
"sale_type"
],
goods_data
[
"ac_type"
],
goods_data
[
"order_goods_type"
],
goods_data
[
"buyer_id"
],
goods_data
[
"goods_price"
])
if
err
!=
nil
{
logger
.
Info
(
"新增订单明细表失败,原因:"
+
err
.
Error
())
conn
.
Rollback
()
//回滚
return
}
ItemLastInsertId
,
_
:=
relt
.
LastInsertId
()
// 明细自增ID
_
,
err
=
conn
.
Exec
(
"insert into lie_order_items_ext (order_id, rec_id, batch) values (?, ?, ?)"
,
order_id
,
ItemLastInsertId
,
item_ext
.
Batch
)
if
err
!=
nil
{
logger
.
Info
(
"新增订单明细扩展表失败,原因:"
+
err
.
Error
())
conn
.
Rollback
()
//回滚
return
}
...
...
@@ -208,6 +225,7 @@ func CreateOrder(create_time int64) {
_
,
err
=
conn
.
Exec
(
"insert into lie_other_address (order_id, address_id, order_sn, province, city, district, address, consignee, mobile) "
+
"values (?, ?, ?, ?, ?, ?, ?, ?, ?)"
,
order_id
,
0
,
order_sn
,
0
,
0
,
0
,
order_address
.
Address
,
order_address
.
Lianxiren
,
order_address
.
Telphone
)
if
err
!=
nil
{
logger
.
Info
(
"新增订单地址表失败,原因:"
+
err
.
Error
())
conn
.
Rollback
()
//回滚
return
}
...
...
@@ -220,6 +238,7 @@ func CreateOrder(create_time int64) {
_
,
err
=
conn
.
Exec
(
"insert into lie_pay_log (user_id, order_id, order_sn, pay_name, pay_amount, is_paid, create_time, pay_time) values (?, ?, ?, ?, ?, ?, ?, ?)"
,
user_id
,
order_id
,
order_sn
,
pay_name
,
order_amount
,
1
,
last_time
,
last_time
)
if
err
!=
nil
{
logger
.
Info
(
"新增订单支付表失败,原因:"
+
err
.
Error
())
conn
.
Rollback
()
//回滚
return
}
...
...
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