Ver código fonte

1、关联查询排序问题;

Lawsun 1 ano atrás
pai
commit
a7791690f6

+ 31 - 31
.idea/workspace.xml

@@ -1,11 +1,10 @@
 <?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/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" />
@@ -49,27 +48,27 @@
     <option name="hideEmptyMiddlePackages" value="true" />
     <option name="showLibraryContents" value="true" />
   </component>
-  <component name="PropertiesComponent"><![CDATA[{
-  "keyToString": {
-    "ASKED_MARK_IGNORED_FILES_AS_EXCLUDED": "true",
-    "RunOnceActivity.OpenProjectViewOnStart": "true",
-    "RunOnceActivity.ShowReadmeOnStart": "true",
-    "SHARE_PROJECT_CONFIGURATION_FILES": "true",
-    "WebServerToolWindowFactoryState": "false",
-    "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",
-    "settings.editor.selected.configurable": "advanced.settings",
-    "ts.external.directory.path": "D:\\Program Files (x86)\\WebStorm 2022.2.1\\plugins\\JavaScriptLanguage\\jsLanguageServicesImpl\\external",
-    "vue.rearranger.settings.migration": "true"
+  <component name="PropertiesComponent">{
+  &quot;keyToString&quot;: {
+    &quot;ASKED_MARK_IGNORED_FILES_AS_EXCLUDED&quot;: &quot;true&quot;,
+    &quot;RunOnceActivity.OpenProjectViewOnStart&quot;: &quot;true&quot;,
+    &quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
+    &quot;SHARE_PROJECT_CONFIGURATION_FILES&quot;: &quot;true&quot;,
+    &quot;WebServerToolWindowFactoryState&quot;: &quot;false&quot;,
+    &quot;last_opened_file_path&quot;: &quot;D:/ysjjCode/shop-system/app/service&quot;,
+    &quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
+    &quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
+    &quot;nodejs_package_manager_path&quot;: &quot;npm&quot;,
+    &quot;settings.editor.selected.configurable&quot;: &quot;advanced.settings&quot;,
+    &quot;ts.external.directory.path&quot;: &quot;D:\\Program Files (x86)\\WebStorm 2022.2.1\\plugins\\JavaScriptLanguage\\jsLanguageServicesImpl\\external&quot;,
+    &quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
   },
-  "keyToStringList": {
-    "DatabaseDriversLRU": [
-      "mysql"
+  &quot;keyToStringList&quot;: {
+    &quot;DatabaseDriversLRU&quot;: [
+      &quot;mysql&quot;
     ]
   }
-}]]></component>
+}</component>
   <component name="RecentsManager">
     <key name="CopyFile.RECENT_KEYS">
       <recent name="D:\ysjjCode\shop-system\app\service" />
@@ -274,14 +273,8 @@
       <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>
-      <option name="number" value="00027" />
-      <option name="presentableId" value="LOCAL-00027" />
-      <option name="project" value="LOCAL" />
-      <updated>1672466361911</updated>
+      <workItem from="1693965606793" duration="9192000" />
+      <workItem from="1694742935995" duration="7444000" />
     </task>
     <task id="LOCAL-00028" summary="1.用户可选是否使用余额抵扣;">
       <created>1672818757250</created>
@@ -619,7 +612,14 @@
       <option name="project" value="LOCAL" />
       <updated>1693131061954</updated>
     </task>
-    <option name="localTasksCounter" value="76" />
+    <task id="LOCAL-00076" summary="1、分类商品列表查询全部;">
+      <created>1694075503571</created>
+      <option name="number" value="00076" />
+      <option name="presentableId" value="LOCAL-00076" />
+      <option name="project" value="LOCAL" />
+      <updated>1694075503571</updated>
+    </task>
+    <option name="localTasksCounter" value="77" />
     <servers />
   </component>
   <component name="TypeScriptGeneratedFilesManager">
@@ -665,7 +665,6 @@
     </option>
   </component>
   <component name="VcsManagerConfiguration">
-    <MESSAGE value="1.参数错误文案调整;" />
     <MESSAGE value="1.补充所有合作餐店可以核销通用电子餐费的逻辑;" />
     <MESSAGE value="1.餐店和普通客户区别分佣比例;" />
     <MESSAGE value="1.查询所有餐店;" />
@@ -690,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>

+ 6 - 4
app/controller/home/productCategory.js

@@ -51,7 +51,7 @@ module.exports = class ProductCategoryController extends shopController {
     try {
       let result = await that.service.redis.get(that.cacheKey);
       if (!result) {
-        result = await that.useModel.findAll({
+        const opt = {
           where: { is_show: 1 },
           include: [
             {
@@ -60,13 +60,15 @@ module.exports = class ProductCategoryController extends shopController {
               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' ]],
-        });
+          // 2023/9/15 关联查询排序
+          order: [[ 'category_id', 'asc' ], [ 'products', 'is_hot', 'desc' ], [ 'products', 'is_new', 'desc' ], [ 'products', 'sale_count', 'desc' ]],
+        };
+        const selectBean = await that.app.comoBean.instance({}, opt);
+        result = await that.service.manager.select(selectBean, that.useModel, '商品列表查看失败,请重试', false, true);
         if (result) await that.service.redis.set(that.cacheKey, result, that.cacheTime);
       }
       return that.ctx.appJson(that.app.szjcomo.appResult('SUCCESS', result, false));

Diferenças do arquivo suprimidas por serem muito extensas
+ 0 - 0
node_modules/egg-ts-helper/.tmp/eggInfo.json


Alguns arquivos não foram mostrados porque muitos arquivos mudaram nesse diff