瀏覽代碼

小程序首页

eganwu 1 年之前
父節點
當前提交
e8c2d0bc0f
共有 2 個文件被更改,包括 46 次插入0 次删除
  1. 5 0
      src/custom/restcontroller/R.java
  2. 41 0
      src/custom/restcontroller/webmanage/saletool/store/Store.java

+ 5 - 0
src/custom/restcontroller/R.java

@@ -6039,6 +6039,11 @@ public class R {
         }
     }
 
+    public static class ID20240416153202 {
+        public static class v1 {
+        }
+    }
+
 
 }
 

+ 41 - 0
src/custom/restcontroller/webmanage/saletool/store/Store.java

@@ -174,4 +174,45 @@ public class Store extends Controller {
 
     }
 
+
+    @API(title = "小程序门店首页", apiversion = R.ID20240416153202.v1.class)
+    public String appletHome() throws YosException {
+
+        String longitude = content.getStringValue("longitude");
+        String latitude = content.getStringValue("latitude");
+
+
+        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_store").setTableAlias("t1");
+        querySQL.addJoinTable(JOINTYPE.left,"sys_enterprise_hr","t2","t2.sys_enterprise_hrid=t1.leader_hrid and t2.siteid=t1.siteid"
+                ,"name");
+        querySQL.addQueryFields("distance", "st_distance_sphere(point(longitude,latitude),point('" + longitude + "','" + latitude + "'))");
+        querySQL.setOrderBy("distance");
+        Rows rows = querySQL.query();
+        Row detailRow = rows.isNotEmpty() ? rows.get(0) : new Row();
+        detailRow.put("distance", String.format("%.2f", detailRow.getDouble("distance")));
+
+        long sa_storeid = detailRow.getLong("sa_storeid");
+        detailRow.put("attinfos", Attachment.get(this,"sa_store", sa_storeid));
+
+        Rows adspaceRows = dbConnect.runSqlQuery("SELECT * from sys_adspace WHERE systemclient='wechatsaletool' and isused=1");
+
+        for (Row adspaceRow : adspaceRows) {
+            Long sys_adspaceid = adspaceRow.getLong("sys_adspaceid");
+            querySQL = SQLFactory.createQuerySQL(this, "sys_ad")
+                    .setTableAlias("t1");
+            querySQL.setSiteid(siteid);
+            querySQL.setWhere("sys_adspaceid", sys_adspaceid);
+            querySQL.setDataAuth(true);
+            Rows adRows = querySQL.query();
+            RowsMap attinfosRowsMap = Attachment.get(this, "sys_ad", adRows.toArrayList("sys_adid", new ArrayList<>()));
+            for (Row row : adRows) {
+                row.put("attinfos", attinfosRowsMap.getOrDefault(row.getString("sys_adid"), new Rows()));
+            }
+            detailRow.put("ad_" + adspaceRow.getString("location"), adRows);
+        }
+
+
+        return getSucReturnObject().setData(detailRow).toString();
+    }
+
 }