Commit 1e9e5713 by 朱继来

调整竞调订单

parent c6ea3408
package OrderItemsExt
type OrderItemsExt struct {
RecId int `db:"rec_id"`
Batch string `db:"batch"`
}
...@@ -66,7 +66,7 @@ func GetOneOrderItem() OrderItems.OrderItems { ...@@ -66,7 +66,7 @@ func GetOneOrderItem() OrderItems.OrderItems {
var order_item 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," + 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 " + 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") "on a.rec_id > b.brec_id and a.goods_price > 0.1 LIMIT 1")
......
...@@ -8,6 +8,7 @@ import ( ...@@ -8,6 +8,7 @@ import (
"go-queue-server/dal/order/JingdiaoAddress" "go-queue-server/dal/order/JingdiaoAddress"
"go-queue-server/dal/order/Order" "go-queue-server/dal/order/Order"
"go-queue-server/dal/order/OrderItems" "go-queue-server/dal/order/OrderItems"
"go-queue-server/dal/order/OrderItemsExt"
_"go-queue-server/dal/order/OtherAddress" _"go-queue-server/dal/order/OtherAddress"
"go-queue-server/order/jingdiao/handle" "go-queue-server/order/jingdiao/handle"
"go-queue-server/util" "go-queue-server/util"
...@@ -136,6 +137,7 @@ func CreateOrder(create_time int64) { ...@@ -136,6 +137,7 @@ func CreateOrder(create_time int64) {
// 订单数据 // 订单数据
order := make(map[string]interface{}, 0) order := make(map[string]interface{}, 0)
goods_data := 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["order_sn"] = order_sn
order["user_id"] = user_id order["user_id"] = user_id
...@@ -165,10 +167,13 @@ func CreateOrder(create_time int64) { ...@@ -165,10 +167,13 @@ func CreateOrder(create_time int64) {
goods_data["ac_type"] = order_item.AcType goods_data["ac_type"] = order_item.AcType
goods_data["order_goods_type"] = order_item.OrderGoodsType goods_data["order_goods_type"] = order_item.OrderGoodsType
goods_data["buyer_id"] = order_item.BuyerId 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() // 开启事务 conn, err := db.OrderDB.Begin() // 开启事务
if err != nil { if err != nil {
logger.Info("开启事务失败,原因:" + err.Error())
return return
} }
...@@ -178,6 +183,7 @@ func CreateOrder(create_time int64) { ...@@ -178,6 +183,7 @@ func CreateOrder(create_time int64) {
LastInsertId, err := res.LastInsertId() LastInsertId, err := res.LastInsertId()
if err != nil { if err != nil {
logger.Info("新增订单表失败,原因:" + err.Error())
conn.Rollback() //回滚 conn.Rollback() //回滚
return return
} }
...@@ -188,18 +194,29 @@ func CreateOrder(create_time int64) { ...@@ -188,18 +194,29 @@ func CreateOrder(create_time int64) {
// 添加lie_order_extend // 添加lie_order_extend
_, err = conn.Exec("insert into lie_order_extend (order_id, is_manager_audit) values (?, ?)", order_id, 3) _, err = conn.Exec("insert into lie_order_extend (order_id, is_manager_audit) values (?, ?)", order_id, 3)
if err != nil { if err != nil {
logger.Info("新增订单扩展表失败,原因:" + err.Error())
conn.Rollback() //回滚 conn.Rollback() //回滚
return return
} }
// 添加lie_order_items // 添加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, " + 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, batch, single_pre_price) values (?, ?, ?, ?, " + "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"], "?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", 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_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["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 { if err != nil {
logger.Info("新增订单明细扩展表失败,原因:" + err.Error())
conn.Rollback() //回滚 conn.Rollback() //回滚
return return
} }
...@@ -208,6 +225,7 @@ func CreateOrder(create_time int64) { ...@@ -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) " + _, 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) "values (?, ?, ?, ?, ?, ?, ?, ?, ?)", order_id, 0, order_sn, 0, 0, 0, order_address.Address, order_address.Lianxiren, order_address.Telphone)
if err != nil { if err != nil {
logger.Info("新增订单地址表失败,原因:" + err.Error())
conn.Rollback() //回滚 conn.Rollback() //回滚
return return
} }
...@@ -220,6 +238,7 @@ func CreateOrder(create_time int64) { ...@@ -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, _, 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) order_id, order_sn, pay_name, order_amount, 1, last_time, last_time)
if err != nil { if err != nil {
logger.Info("新增订单支付表失败,原因:" + err.Error())
conn.Rollback() //回滚 conn.Rollback() //回滚
return return
} }
......
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