Commit b66cb1eb by wkliang

分转元

parent d768840b
......@@ -9,7 +9,6 @@ class ProductService extends ServiceBase {
async getPage (page, limit, type, keywords) {
let result = await this.dao.getPage(page, limit, type, keywords)
for (let i = 0; i < result.rows.length; ++i) {
console.log(result[i])
if (result.rows[i].price) {
result.rows[i].setDataValue("price", result.rows[i].price / 100)
}
......@@ -58,7 +57,13 @@ class ProductService extends ServiceBase {
}
async getByIds (ids) {
return await this.dao.getByIds(ids)
let result = await this.dao.getByIds(ids)
for (let i = 0; i < result.rows.length; ++i) {
if (result.rows[i].price) {
result.rows[i].setDataValue("price", result.rows[i].price / 100)
}
}
return result
}
async getItems (id) {
......@@ -73,6 +78,11 @@ class ProductService extends ServiceBase {
arr.push(i.product_id)
}
let result = await this.dao.getByIds(arr)
for (let i in result) {
if (result[i].price) {
result[i].setDataValue("price", result[i].price / 100)
}
}
let res = result.map((data) => {
return data.id
})
......@@ -80,6 +90,7 @@ class ProductService extends ServiceBase {
ans.items = result
ans.ids = res
let pro = await this.dao.model.findOne({ where: { id: id } })
pro.setDataValue("price", pro.price / 100)
ans.pro = pro
return ans
}
......
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 to comment