- 去除OrderManager.getOrders中不必要的事务
This commit is contained in:
@@ -358,6 +358,7 @@ func (c *OrderManager) getOrders(ctx *jxcontext.Context, isIncludeSku bool, from
|
|||||||
sqlParams = append(sqlParams, vendorIDs)
|
sqlParams = append(sqlParams, vendorIDs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
db := dao.GetDB()
|
||||||
sql += sqlWhere
|
sql += sqlWhere
|
||||||
if isIncludeSku {
|
if isIncludeSku {
|
||||||
sql += `
|
sql += `
|
||||||
@@ -367,9 +368,7 @@ func (c *OrderManager) getOrders(ctx *jxcontext.Context, isIncludeSku bool, from
|
|||||||
ORDER BY t1.order_created_at DESC
|
ORDER BY t1.order_created_at DESC
|
||||||
LIMIT ? OFFSET ?`
|
LIMIT ? OFFSET ?`
|
||||||
sqlParams = append(sqlParams, pageSize, offset)
|
sqlParams = append(sqlParams, pageSize, offset)
|
||||||
}
|
|
||||||
|
|
||||||
db := dao.GetDB()
|
|
||||||
dao.Begin(db)
|
dao.Begin(db)
|
||||||
defer func() {
|
defer func() {
|
||||||
if r := recover(); r != nil {
|
if r := recover(); r != nil {
|
||||||
@@ -377,10 +376,13 @@ func (c *OrderManager) getOrders(ctx *jxcontext.Context, isIncludeSku bool, from
|
|||||||
panic(r)
|
panic(r)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
}
|
||||||
if err = dao.GetRows(db, &orders, sql, sqlParams...); err == nil {
|
if err = dao.GetRows(db, &orders, sql, sqlParams...); err == nil {
|
||||||
totalCount = dao.GetLastTotalRowCount(db)
|
totalCount = dao.GetLastTotalRowCount(db)
|
||||||
}
|
}
|
||||||
|
if !isIncludeSku {
|
||||||
dao.Commit(db)
|
dao.Commit(db)
|
||||||
|
}
|
||||||
return orders, totalCount, err
|
return orders, totalCount, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user