shopPost.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. const Parse = getApp().Parse;
  2. const company = getApp().globalData.company
  3. const date = require("../../utils/date");
  4. const reqSql = require("../utils/request")
  5. function getShopPost(id) {
  6. return new Promise((resolve, reject) => {
  7. let post = new Parse.Query("ShopOrder")
  8. post.equalTo("goods", id)
  9. post.equalTo("status", 800)
  10. post.count().then(res => {
  11. console.log(res);
  12. resolve(res)
  13. })
  14. })
  15. }
  16. async function getOrders(id, limit, length) {
  17. let sql = `select sp.user,sp.status,sp.images,sp.score,sp.open,sp.content,sp."updatedAt",
  18. us.avatar,us.nickname
  19. from "ShopOrder" as sp
  20. join "_User" as us
  21. on sp.user = us."objectId"
  22. where sp.company = '${company}'
  23. and sp.goods = '${id}'
  24. and sp.status = 800
  25. order by sp."updatedAt" DESC
  26. limit ${limit ? limit : 200}
  27. offset ${length}
  28. `
  29. let res = await reqSql.customSQL(sql)
  30. let orders = res.reduce((arr, item) => {
  31. item.date = date.formatTime("YYYY-mm-dd", item.updatedAt)
  32. arr.push(item)
  33. return arr
  34. }, [])
  35. console.log(orders);
  36. return orders
  37. }
  38. module.exports = {
  39. getShopPost,
  40. getOrders
  41. }