Commit b66cb1eb by wkliang

分转元

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