lrf 2 gadi atpakaļ
vecāks
revīzija
1bdd81b1c5

+ 1 - 1
app/service/trade/order.js

@@ -93,7 +93,7 @@ class OrderService extends CrudService {
       if (coupon.length > 0) await this.ctx.service.user.userCoupon.useCoupon(coupon, this.tran);
       await this.tran.run();
       // 创建定时任务(mq死信机制任务)
-      // await this.toMakeTask(order_id);
+      await this.toMakeTask(order_id);
       return order_id;
     } catch (error) {
       await this.tran.rollback();

+ 20 - 0
app/service/trade/orderDetail.js

@@ -15,6 +15,7 @@ class OrderDetailService extends CrudService {
     this.userCouponModel = this.ctx.model.User.UserCoupon;
     this.goodsRateModel = this.ctx.model.Shop.GoodsRate;
     this.afterSaleModel = this.ctx.model.Trade.AfterSale;
+    this.platformActModel = this.ctx.model.System.PlatformAct;
     this.tran = new Transaction();
   }
   async searchOrderTransport({ id, goods_id }) {
@@ -139,9 +140,28 @@ class OrderDetailService extends CrudService {
       } else g.is_rate = false;
     }
     res.goods = goods;
+    // 整理total_detail为列表:让前端显示更方便
+    const total_detail = _.get(res, 'total_detail', {});
+    res.total_detail = await this.fetchResetTotalDetail(total_detail);
     return res;
   }
 
+  async fetchResetTotalDetail(total_detail) {
+    const tarr = [];
+    if (_.isNumber(_.get(total_detail, 'goods_total', 0))) tarr.push({ key: 'goods_total', zh: '商品总价', money: _.get(total_detail, 'goods_total', 0) });
+    if (_.isNumber(_.get(total_detail, 'freight_total', 0))) tarr.push({ key: 'freight_total', zh: '运费总价', money: _.get(total_detail, 'freight_total', 0) });
+    const act = _.get(total_detail, 'act', []);
+    for (const a of act) {
+      const { platform_act, platform_act_type, discount } = a;
+      const text = `满${platform_act_type === '6' ? '折' : '减'}活动`;
+      const actData = await this.platformActModel.findById(platform_act);
+      const title = _.get(actData, 'act_time.title', text);
+      const obj = { key: platform_act, zh: title, money: this.ctx.minus(0, discount) };
+      tarr.push(obj);
+    }
+    return tarr;
+  }
+
   async query(filter, { skip = 0, limit, sort, desc, projection } = {}) {
     // 处理排序
     if (sort && _.isString(sort)) {

+ 1 - 1
app/service/view/goods.js

@@ -274,7 +274,7 @@ class GoodsService extends CrudService {
           if (lp && this.ctx.minus(lp, sell_money) < 0) goods.sell_money = lp;
         } else if (type === '5' && gjaList.length > 0) p_act.push('满减');
         else if (type === '6' && gjaList.length > 0) p_act.push('满折');
-        goods.p_act = p_act;
+        goods.p_act = _.uniq(p_act);
       }
     }
   }