|
@@ -7,7 +7,7 @@ module.exports = class extends Base {
|
|
* @return {Promise} []
|
|
* @return {Promise} []
|
|
*/
|
|
*/
|
|
async listAction() {
|
|
async listAction() {
|
|
- const orderList = await this.model('order').where({ user_id: think.userId }).page(1, 10).countSelect();
|
|
|
|
|
|
+ const orderList = await this.model('order').where({ user_id: this.getLoginUserId() }).page(1, 10).countSelect();
|
|
const newOrderList = [];
|
|
const newOrderList = [];
|
|
for (const item of orderList.data) {
|
|
for (const item of orderList.data) {
|
|
// 订单的商品
|
|
// 订单的商品
|
|
@@ -32,7 +32,7 @@ module.exports = class extends Base {
|
|
|
|
|
|
async detailAction() {
|
|
async detailAction() {
|
|
const orderId = this.get('orderId');
|
|
const orderId = this.get('orderId');
|
|
- const orderInfo = await this.model('order').where({ user_id: 1, id: orderId }).find();
|
|
|
|
|
|
+ const orderInfo = await this.model('order').where({ user_id: this.getLoginUserId(), id: orderId }).find();
|
|
|
|
|
|
if (think.isEmpty(orderInfo)) {
|
|
if (think.isEmpty(orderInfo)) {
|
|
return this.fail('订单不存在');
|
|
return this.fail('订单不存在');
|
|
@@ -85,7 +85,7 @@ module.exports = class extends Base {
|
|
const freightPrice = 0.00;
|
|
const freightPrice = 0.00;
|
|
|
|
|
|
// 获取要购买的商品
|
|
// 获取要购买的商品
|
|
- const checkedGoodsList = await this.model('cart').where({ user_id: think.userId, session_id: 1, checked: 1 }).select();
|
|
|
|
|
|
+ const checkedGoodsList = await this.model('cart').where({ user_id: this.getLoginUserId(), session_id: 1, checked: 1 }).select();
|
|
if (think.isEmpty(checkedGoodsList)) {
|
|
if (think.isEmpty(checkedGoodsList)) {
|
|
return this.fail('请选择商品');
|
|
return this.fail('请选择商品');
|
|
}
|
|
}
|
|
@@ -110,7 +110,7 @@ module.exports = class extends Base {
|
|
|
|
|
|
const orderInfo = {
|
|
const orderInfo = {
|
|
order_sn: this.model('order').generateOrderNumber(),
|
|
order_sn: this.model('order').generateOrderNumber(),
|
|
- user_id: think.userId,
|
|
|
|
|
|
+ user_id: this.getLoginUserId(),
|
|
|
|
|
|
// 收货地址和运费
|
|
// 收货地址和运费
|
|
consignee: checkedAddress.name,
|
|
consignee: checkedAddress.name,
|
|
@@ -160,7 +160,7 @@ module.exports = class extends Base {
|
|
}
|
|
}
|
|
|
|
|
|
await this.model('order_goods').addMany(orderGoodsData);
|
|
await this.model('order_goods').addMany(orderGoodsData);
|
|
- await this.model('cart').clearBuyGoods();
|
|
|
|
|
|
+ await this.model('cart').clearBuyGoods(this.getLoginUserId());
|
|
|
|
|
|
return this.success({ orderInfo: orderInfo });
|
|
return this.success({ orderInfo: orderInfo });
|
|
}
|
|
}
|