Created
December 27, 2016 15:12
-
-
Save ZZR-china/dde90873438d817b4d92591025beac6e to your computer and use it in GitHub Desktop.
co is awesome!!!!!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
insertOrderItem(req, reply) { | |
const order_id = req.payload.order_id; | |
const product_id = req.payload.product_id; | |
const msg = new message(); | |
co(function*() { | |
const product = yield Product.get({ _id: product_id }); | |
const menu = yield Menu.get({ _id: product.menu_id }); | |
const order_item_doc = yield new Orderitem({ | |
is_add: true, | |
order_id: order_id, | |
menu_id: menu._id, | |
menu_name: menu.name, | |
product_id: product._id, | |
product_name: product.name, | |
price: product.price, | |
img: product.img_url, | |
spec: product.unit, | |
total: product.price, | |
actual_payment: product.price, | |
printer_num: menu.printer_num | |
}); | |
const order_item = yield order_item_doc.save(); | |
const total = yield this.updateOrderTotal(order_id); | |
return reply(msg.success(total)); | |
}).catch(err => { | |
console.error(err); | |
return reply(msg.fail(err)) | |
}); | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment