lrf 2 年 前
コミット
35b82c8779

+ 1 - 0
app/model/system/config.js

@@ -6,6 +6,7 @@ const configProp = {
   share: { type: Array, zh: '分享图片' },
   share: { type: Array, zh: '分享图片' },
   buyPoint: { type: Number, zh: '购物赠送积分' }, // 金额 / buyPoint 为实际获得积分
   buyPoint: { type: Number, zh: '购物赠送积分' }, // 金额 / buyPoint 为实际获得积分
   pointPlan: { type: Array, zh: '积分计划' }, // 后续有待制作,目前全靠新写
   pointPlan: { type: Array, zh: '积分计划' }, // 后续有待制作,目前全靠新写
+  autoCloseOrder: { type: Number, zh: '自动关闭订单时间' }, // <=0时不自动关闭
 };
 };
 // 系统设置
 // 系统设置
 const config = {
 const config = {

+ 4 - 0
app/service/trade/order.js

@@ -321,6 +321,10 @@ class OrderService extends CrudService {
   async toMakeTask(order_id) {
   async toMakeTask(order_id) {
     const { taskMqConfig } = this.app.config;
     const { taskMqConfig } = this.app.config;
     const data = { service: 'trade.order', method: 'cancel', params: { order_id } };
     const data = { service: 'trade.order', method: 'cancel', params: { order_id } };
+    const config = await this.ctx.service.system.config.query();
+    const setting = _.get(config, 'config.autoCloseOrder', -1);
+    // 设置为小于等于0时,不进行自动关闭
+    if (setting <= 0) return;
     await this.ctx.service.util.rabbitMq.makeTask(taskMqConfig.queue, data, 15);
     await this.ctx.service.util.rabbitMq.makeTask(taskMqConfig.queue, data, 15);
   }
   }
 }
 }

+ 3 - 0
app/service/view/goods.js

@@ -18,6 +18,7 @@ class GoodsService extends CrudService {
    * @param query.id 商品数据id
    * @param query.id 商品数据id
    */
    */
   async goodsDetail({ id }) {
   async goodsDetail({ id }) {
+    // TODO 添加宝贝数,商店3个评价
     const { populate } = this.ctx.service.shop.goods.getRefMods();
     const { populate } = this.ctx.service.shop.goods.getRefMods();
     let goods = await this.goodsModel.findById(id, { file: 1, tags: 1, name: 1, shot_brief: 1, brief: 1, send_time: 1, shop: 1, view_num: 1 }).populate(populate);
     let goods = await this.goodsModel.findById(id, { file: 1, tags: 1, name: 1, shot_brief: 1, brief: 1, send_time: 1, shop: 1, view_num: 1 }).populate(populate);
     if (!goods) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到商品数据');
     if (!goods) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到商品数据');
@@ -27,6 +28,8 @@ class GoodsService extends CrudService {
     goods = _.omit(goods, [ 'meta', '__v' ]);
     goods = _.omit(goods, [ 'meta', '__v' ]);
     const shop = _.pick(goods.shop, [ 'logo', 'name', 'person', 'phone', '_id' ]);
     const shop = _.pick(goods.shop, [ 'logo', 'name', 'person', 'phone', '_id' ]);
     delete goods.shop;
     delete goods.shop;
+    const goodsNum = await this.goodsModel.count({ shop });
+    shop.goods_num = goodsNum;
     // 2022-10-17反馈问题6:将规格图片和商品图片合并,规格图片在前
     // 2022-10-17反馈问题6:将规格图片和商品图片合并,规格图片在前
     for (const spec of specs) {
     for (const spec of specs) {
       if (_.isArray(spec.file)) {
       if (_.isArray(spec.file)) {

+ 3 - 3
config/config.default.js

@@ -66,9 +66,9 @@ module.exports = appInfo => {
   config.amqp = {
   config.amqp = {
     client: {
     client: {
       hostname: 'broadcast.waityou24.cn',
       hostname: 'broadcast.waityou24.cn',
-      username: 'tehq',
-      password: 'tehq',
-      vhost: 'tehq',
+      username: 'tehqDev',
+      password: 'tehqDev',
+      vhost: 'tehqDev',
     },
     },
     app: true,
     app: true,
     agent: true,
     agent: true,