Jelajahi Sumber

1、修复 bug

Lawsun_M 1 tahun lalu
induk
melakukan
06b84799bf
1 mengubah file dengan 2 tambahan dan 25 penghapusan
  1. 2 25
      app/controller/manager/shops/products.js

+ 2 - 25
app/controller/manager/shops/products.js

@@ -132,7 +132,7 @@ module.exports = class ProductsController extends ManagerController {
         .notEmpty()
         .number()
         .extend(async (field, value, row) => {
-          if (row.carousel_id && row.carousel_id > 0) {
+          if (row.carousel_id) {
             const tmpContent = await that.ctx.postParse('content', '', val => val);
             const result = await that.useCarouseModel.update({
               content: tmpContent,
@@ -142,16 +142,8 @@ module.exports = class ProductsController extends ManagerController {
               where: { carousel_id: row.carousel_id },
             });
             if (!result) return '商品相册更新失败,请重试';
-          } else {
-            const tmpContent = await that.ctx.postParse('content', '', val => val);
-            const result = await that.useCarouseModel.create({
-              content: tmpContent,
-              admin_id: that.service.manager.ActionAdminUserId(),
-              create_time: that.app.szjcomo.date('Y-m-d H:i:s'),
-            });
-            if (result) row.carousel_id = result.carousel_id;
           }
-          if (row.content_id && row.content_id > 0) {
+          if (row.content_id) {
             const tmpDesction = await that.ctx.postParse('desction', '', val => val);
             const result = await that.useContentModel.update({
               desction: tmpDesction,
@@ -161,15 +153,6 @@ module.exports = class ProductsController extends ManagerController {
               where: { content_id: row.content_id },
             });
             if (!result) return '商品详情更新失败,请重试';
-          } else {
-            // fix 上传详情失败时 重新补充详情内容
-            const tmpDesction = await that.ctx.postParse('desction', '', val => val);
-            const result = await that.useContentModel.create({
-              desction: tmpDesction,
-              admin_id: that.service.manager.ActionAdminUserId(),
-              create_time: that.app.szjcomo.date('Y-m-d H:i:s'),
-            });
-            if (result) row.content_id = result.content_id;
           }
         }),
       admin_id: that.ctx.rules.default(that.service.manager.ActionAdminUserId())
@@ -304,12 +287,6 @@ module.exports = class ProductsController extends ManagerController {
       const updateBean = await that.app.comoBean.instance(data, {
         where: { product_id: data.product_id }, transaction,
       });
-      if (data.carousel_id < 1) {
-        throw new Error('图册提交失败,请重试');
-      }
-      if (data.content_id < 1) {
-        throw new Error('详情内容提交失败,请重试');
-      }
       const result = await that.service.manager.update(updateBean, that.useModel, '商品更新失败,请稍候重试');
       await that.productActionAfter(data.product_id, transaction);
       await transaction.commit();