Commit 9b78daed by 朱继来

调整明细

parent 35331dd5
Showing with 15 additions and 9 deletions
...@@ -50,19 +50,25 @@ func GetJingDiaoUserId() int { ...@@ -50,19 +50,25 @@ func GetJingDiaoUserId() int {
// 随机获取一条商品明细 // 随机获取一条商品明细
func GetOneOrderItem() OrderItems.OrderItems { func GetOneOrderItem() OrderItems.OrderItems {
var count int //var count int
db.DB.QueryRow("select count(*) from lie_order_items where goods_id != ? and goods_price > ? and status = ?", 0, 0.1, 1).Scan(&count) //db.DB.QueryRow("select count(*) from lie_order_items where goods_id != ? and goods_price > ? and status = ?", 0, 0.1, 1).Scan(&count)
//
rand_num := RandInt(1, count) // 从总数中取个随机数 //rand_num := RandInt(1, count) // 从总数中取个随机数
//
//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"
//db.DB.Get(&order_item, "select "+field+" from lie_order_items where rec_id = ? and goods_id != ? and goods_price > ? and status = ?", rand_num, 0, 0.1, 1)
//
//if order_item.RecId == 0 {
// return GetOneOrderItem()
//}
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,batch"
db.DB.Get(&order_item, "select "+field+" from lie_order_items where rec_id = ? and goods_id != ? and goods_price > ? and status = ?", rand_num, 0, 0.1, 1) db.DB.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")
if order_item.RecId == 0 {
return GetOneOrderItem()
}
return order_item return order_item
} }
......
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