|
|
@@ -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();
|
|
|
+ }
|
|
|
+
|
|
|
}
|