Browse Source

add 店铺数据

warrior 4 months ago
parent
commit
b5fea9e4c2
2 changed files with 44 additions and 0 deletions
  1. 7 0
      nova-tourism/components/homestay/index.js
  2. 37 0
      nova-tourism/service/request.js

+ 7 - 0
nova-tourism/components/homestay/index.js

@@ -1,5 +1,6 @@
 let Parse = getApp().Parse;
 const company = getApp().globalData.company
+const { getStores } = require(".././../service/request")
 Component({
     /**
      * 组件的属性列表
@@ -163,6 +164,12 @@ Component({
         },
         //获取店铺消息
         async gethomestar() {
+          let _data = await getStores({
+            uid:Parse.User.current().id,
+            skip:0,
+            limit:10
+          })
+          console.log('店铺数据=====>',_data);
             let ShopStore = new Parse.Query('ShopStore');
             ShopStore.equalTo('company', company);
             ShopStore.equalTo('type', "stay");

+ 37 - 0
nova-tourism/service/request.js

@@ -0,0 +1,37 @@
+const req = require('../../utils/request')
+// let Parse = getApp().Parse;
+const company = getApp().globalData.company
+
+async function getStores(params) {
+  let {
+    uid,
+    skip,
+    limit
+  } = params
+  let sql = `SELECT * ,
+  ("perCapita" * 1) price,
+  (SELECT room."price" FROM "ShopRoom" room 
+   WHERE room."shop" = store."objectId"
+   AND room."isDeleted" IS NOT TRUE
+   ORDER BY room."price" ASC LIMIT 1
+  ) "minPrice",
+  (SELECT clt."isCollect" FROM "DramaShopCollect" clt 
+   WHERE clt."homestayStore" = store."objectId" 
+   AND clt."isCollect" = TRUE
+   AND clt."isDeleted" IS NOT TRUE
+   AND clt."user" = '${uid}'
+   LIMIT 1 
+  ) "iscollect"
+  
+  FROM "ShopStore" store
+  WHERE "company" = '${company}'
+  AND "type" = 'stay'
+  AND "isDeleted" IS NOT TRUE
+  ORDER BY "iscollect"
+  OFFSET ${skip ?? 0} LIMIT ${limit ?? 10}`
+  let res = await req.customSQL(sql);
+  return res
+}
+module.exports = {
+  getStores
+};