Kaynağa Gözat

1、分类商品列表查询全部;

Lawsun 1 yıl önce
ebeveyn
işleme
1b90e7ef36

+ 24 - 17
.idea/workspace.xml

@@ -1,12 +1,11 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project version="4">
   <component name="ChangeListManager">
-    <list default="true" id="08cfebb0-a4a4-47ee-a307-566aa06f29bb" name="Default Changelist" comment="1、每日用户登录记录;">
+    <list default="true" id="08cfebb0-a4a4-47ee-a307-566aa06f29bb" name="Default Changelist" comment="1、每日用户登录数量查询;">
       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/app/schedule/dayUsers.js" beforeDir="false" afterPath="$PROJECT_DIR$/app/schedule/dayUsers.js" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/app/service/manager.js" beforeDir="false" afterPath="$PROJECT_DIR$/app/service/manager.js" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/app/service/order.js" beforeDir="false" afterPath="$PROJECT_DIR$/app/service/order.js" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/app/controller/home/productCategory.js" beforeDir="false" afterPath="$PROJECT_DIR$/app/controller/home/productCategory.js" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/node_modules/egg-ts-helper/.tmp/eggInfo.json" beforeDir="false" afterPath="$PROJECT_DIR$/node_modules/egg-ts-helper/.tmp/eggInfo.json" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/typings/app/service/index.d.ts" beforeDir="false" afterPath="$PROJECT_DIR$/typings/app/service/index.d.ts" afterDir="false" />
     </list>
     <option name="SHOW_DIALOG" value="false" />
     <option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -57,7 +56,7 @@
     "RunOnceActivity.ShowReadmeOnStart": "true",
     "SHARE_PROJECT_CONFIGURATION_FILES": "true",
     "WebServerToolWindowFactoryState": "false",
-    "last_opened_file_path": "D:/ysjjCode/shop-system/app/models/mysql",
+    "last_opened_file_path": "D:/ysjjCode/shop-system/app/service",
     "node.js.detected.package.eslint": "true",
     "node.js.selected.package.eslint": "(autodetect)",
     "nodejs_package_manager_path": "npm",
@@ -73,10 +72,10 @@
 }]]></component>
   <component name="RecentsManager">
     <key name="CopyFile.RECENT_KEYS">
+      <recent name="D:\ysjjCode\shop-system\app\service" />
       <recent name="D:\ysjjCode\shop-system\app\models\mysql" />
       <recent name="D:\ysjjCode\shop-system\app\schedule" />
       <recent name="D:\ysjjCode\shop-system\app\controller\home" />
-      <recent name="D:\ysjjCode\shop-system\app\service" />
       <recent name="D:\IdeaWorkSpace\wsProjects\shop-system\app\models\mysql" />
     </key>
     <key name="MoveFile.RECENT_KEYS">
@@ -267,14 +266,15 @@
       <workItem from="1692582714108" duration="4090000" />
       <workItem from="1692666690140" duration="5486000" />
       <workItem from="1692752289886" duration="4795000" />
-      <workItem from="1692840290649" duration="36047000" />
-    </task>
-    <task id="LOCAL-00026" summary="1.支持配置无红包优惠的分类,该分类下的商品不能使用红包优惠;">
-      <created>1671899979174</created>
-      <option name="number" value="00026" />
-      <option name="presentableId" value="LOCAL-00026" />
-      <option name="project" value="LOCAL" />
-      <updated>1671899979174</updated>
+      <workItem from="1692840290649" duration="36723000" />
+      <workItem from="1693181862320" duration="1499000" />
+      <workItem from="1693206691778" duration="828000" />
+      <workItem from="1693275184270" duration="5000" />
+      <workItem from="1693278134477" duration="4133000" />
+      <workItem from="1693377127421" duration="1188000" />
+      <workItem from="1693448014632" duration="596000" />
+      <workItem from="1693618204645" duration="54000" />
+      <workItem from="1693965606793" duration="8409000" />
     </task>
     <task id="LOCAL-00027" summary="1.配置字段控制活动分享入口的显示;">
       <created>1672466361911</created>
@@ -612,7 +612,14 @@
       <option name="project" value="LOCAL" />
       <updated>1693124235815</updated>
     </task>
-    <option name="localTasksCounter" value="75" />
+    <task id="LOCAL-00075" summary="1、每日用户登录数量查询;">
+      <created>1693131061954</created>
+      <option name="number" value="00075" />
+      <option name="presentableId" value="LOCAL-00075" />
+      <option name="project" value="LOCAL" />
+      <updated>1693131061954</updated>
+    </task>
+    <option name="localTasksCounter" value="76" />
     <servers />
   </component>
   <component name="TypeScriptGeneratedFilesManager">
@@ -658,7 +665,6 @@
     </option>
   </component>
   <component name="VcsManagerConfiguration">
-    <MESSAGE value="1.补充餐店排序字段;" />
     <MESSAGE value="1.参数错误文案调整;" />
     <MESSAGE value="1.补充所有合作餐店可以核销通用电子餐费的逻辑;" />
     <MESSAGE value="1.餐店和普通客户区别分佣比例;" />
@@ -683,7 +689,8 @@
     <MESSAGE value="1、我邀请的用户活跃列表;" />
     <MESSAGE value="1、时间倒序;" />
     <MESSAGE value="1、每日用户登录记录;" />
-    <option name="LAST_COMMIT_MESSAGE" value="1、每日用户登录记录;" />
+    <MESSAGE value="1、每日用户登录数量查询;" />
+    <option name="LAST_COMMIT_MESSAGE" value="1、每日用户登录数量查询;" />
   </component>
   <component name="XDebuggerManager">
     <breakpoint-manager>

+ 34 - 18
app/controller/home/productCategory.js

@@ -8,6 +8,18 @@ module.exports = class ProductCategoryController extends shopController {
     return that.app.model.ProductCategory;
   }
 
+  /**
+   * [cacheKey 缓存键]
+   * @return {[type]} [description]
+   */
+  get cacheKey() {
+    return `${process.env.APP_CUSTOME || 'universal'}_trees`;
+  }
+
+  get cacheTime() {
+    return 30 * 60;// 2023/9/7 30分钟缓存时间
+  }
+
   /**
    * [categoryValidate 查询分类下商品]
    * @return {[type]} [description]
@@ -37,22 +49,26 @@ module.exports = class ProductCategoryController extends shopController {
   async trees() {
     const that = this;
     try {
-      const result = await that.useModel.findAll({
-        where: { is_show: 1 },
-        include: [
-          {
-            model: that.app.model.Products,
-            as: 'products',
-            attributes: [ 'product_id', 'category_id', 'product_name', 'product_image', 'shop_price', 'market_price', 'is_new', 'is_hot' ],
-            offset: 0,
-            limit: 6,
-            order: [[ 'is_hot', 'desc' ], [ 'is_new', 'desc' ], [ 'product_id', 'asc' ]],
-            where: { is_sale: 1 },
-          },
-        ],
-        attributes: [ 'category_id', [ 'category_name', 'text' ]],
-        order: [[ 'category_id', 'asc' ]],
-      });
+      let result = await that.service.redis.get(that.cacheKey);
+      if (!result) {
+        result = await that.useModel.findAll({
+          where: { is_show: 1 },
+          include: [
+            {
+              model: that.app.model.Products,
+              as: 'products',
+              attributes: [ 'product_id', 'category_id', 'product_name', 'product_image', 'shop_price', 'market_price', 'is_new', 'is_hot' ],
+              // offset: 0,
+              // limit: 6,
+              order: [[ 'is_hot', 'desc' ], [ 'is_new', 'desc' ], [ 'sale_count', 'desc' ]], // , [ 'product_stock', 'desc' ], [ 'product_id', 'asc' ]
+              where: { is_sale: 1 },
+            },
+          ],
+          attributes: [ 'category_id', [ 'category_name', 'text' ]],
+          order: [[ 'category_id', 'asc' ]],
+        });
+        if (result) await that.service.redis.set(that.cacheKey, result, that.cacheTime);
+      }
       return that.ctx.appJson(that.app.szjcomo.appResult('SUCCESS', result, false));
     } catch (err) {
       return that.ctx.appJson(that.app.szjcomo.appResult(err.message));
@@ -69,14 +85,14 @@ module.exports = class ProductCategoryController extends shopController {
       const data = await that.ctx.validate(that.categoryValidate, await that.ctx.getParse());
       const options = {
         where: { category_id: data.category_id, is_sale: 1 },
-        order: [[ 'is_hot', 'desc' ], [ 'is_new', 'desc' ], [ 'product_stock', 'desc' ], [ 'product_id', 'asc' ]],
+        order: [[ 'is_hot', 'desc' ], [ 'is_new', 'desc' ]], // , [ 'product_stock', 'desc' ], [ 'product_id', 'asc' ]
         // offset: (data.page - 1) * data.limit, limit: data.limit,
         attributes: [ 'product_id', 'category_id', 'product_name', 'product_image', 'shop_price', 'market_price', 'is_new', 'is_hot' ],
       };
       if (data.price_sort) options.order.push([ 'shop_price', data.price_sort == 1 ? 'asc' : 'desc' ]);
       if (data.sale_sort) options.order.push([ 'sale_count', data.sale_sort == 1 ? 'asc' : 'desc' ]);
       const selectBean = await that.app.comoBean.instance(data, options);
-      const result = await that.service.manager.select(selectBean, that.app.model.Products, '商品列表查看失败,请重试', true);
+      const result = await that.service.manager.select(selectBean, that.app.model.Products, '商品列表查看失败,请重试', true, true);
       return that.ctx.appJson(that.app.szjcomo.appResult('SUCCESS', result, false));
     } catch (err) {
       return that.ctx.appJson(that.app.szjcomo.appResult(err.message));

Dosya farkı çok büyük olduğundan ihmal edildi
+ 0 - 0
node_modules/egg-ts-helper/.tmp/eggInfo.json


Bu fark içinde çok fazla dosya değişikliği olduğu için bazı dosyalar gösterilmiyor