Forráskód Böngészése

update buy now in order

StephenArk30 5 éve
szülő
commit
1abe400051
1 módosított fájl, 18 hozzáadás és 17 törlés
  1. 18 17
      src/api/controller/order.js

+ 18 - 17
src/api/controller/order.js

@@ -50,7 +50,7 @@ module.exports = class extends Base {
 
     // 订单状态的处理
     orderInfo.order_status_text = await this.model('order').getOrderStatusText(orderId);
-    orderInfo.add_time = moment.unix(orderInfo.add_time).format('YYYY-MM-DD HH:mm:ss');
+    orderInfo.add_time = moment.unix(orderInfo.add_time).format('YYYY-MM-DD HH:mm:ss'); // windows下会出错
     orderInfo.final_pay_time = moment('001234', 'Hmmss').format('mm:ss');
     // 订单最后支付时间
     if (orderInfo.order_status === 0) {
@@ -205,6 +205,7 @@ module.exports = class extends Base {
     const goodsTotalPrice = parseInt(this.post('goodsCount')) * Math.ceil(checkedGoods.retail_price / 50) * 50; // 价格取整
 
     const currentTime = parseInt(this.getTime() / 1000);
+    think.logger.debug(Date.now());
     // 更新用户余额
     const user = await this.model('user').where({id: this.getLoginUserId()}).find();
     if (think.isEmpty(user) || parseInt(user.isAuthen) === 0) return this.fail('用户未注册');
@@ -242,7 +243,9 @@ module.exports = class extends Base {
       add_time: currentTime,
       goods_price: goodsTotalPrice,
       order_price: goodsTotalPrice,
-      actual_price: goodsTotalPrice
+      actual_price: goodsTotalPrice,
+      // 状态:已支付
+      order_status: 1
     };
 
     // 开启事务,插入订单信息和订单商品
@@ -254,21 +257,19 @@ module.exports = class extends Base {
 
     // 统计商品总价
     const orderGoodsData = [];
-    for (let i = 0; i < this.post('goodsCount'); i++) {
-      orderGoodsData.push({
-        order_id: orderId,
-        goods_id: checkedGoods.goods_id,
-        goods_sn: checkedGoods.goods_sn,
-        product_id: checkedGoods.product_id,
-        goods_name: checkedGoods.goods_name,
-        list_pic_url: checkedGoods.list_pic_url,
-        market_price: checkedGoods.market_price,
-        retail_price: checkedGoods.retail_price,
-        number: checkedGoods.number,
-        goods_specifition_name_value: checkedGoods.goods_specifition_name_value,
-        goods_specifition_ids: checkedGoods.goods_specifition_ids
-      });
-    }
+    orderGoodsData.push({
+      order_id: orderId,
+      goods_id: checkedGoods.goods_id,
+      goods_sn: checkedGoods.goods_sn,
+      product_id: checkedGoods.product_id,
+      goods_name: checkedGoods.goods_name,
+      list_pic_url: checkedGoods.list_pic_url,
+      market_price: checkedGoods.market_price,
+      retail_price: checkedGoods.retail_price,
+      number: this.post('goodsCount'),
+      goods_specifition_name_value: checkedGoods.goods_specifition_name_value,
+      goods_specifition_ids: checkedGoods.goods_specifition_ids
+    });
 
     await this.model('order_goods').addMany(orderGoodsData);