فهرست منبع

查询历史门店足迹

eganwu 1 سال پیش
والد
کامیت
3c26793d80
2فایلهای تغییر یافته به همراه62 افزوده شده و 4 حذف شده
  1. 5 0
      src/custom/restcontroller/R.java
  2. 57 4
      src/custom/restcontroller/webmanage/saletool/store/Store.java

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

@@ -6044,6 +6044,11 @@ public class R {
         }
     }
 
+    public static class ID20240416162002 {
+        public static class v1 {
+        }
+    }
+
 
 }
 

+ 57 - 4
src/custom/restcontroller/webmanage/saletool/store/Store.java

@@ -183,16 +183,15 @@ public class Store extends Controller {
 
 
         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.addJoinTable(JOINTYPE.left, "sys_enterprise_hr", "t2", "t2.sys_enterprise_hrid=t1.leader_hrid and t2.siteid=t1.siteid"
+                , "name","phonenumber");
         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));
+        detailRow.put("attinfos", Attachment.get(this, "sa_store", sa_storeid));
 
         Rows adspaceRows = dbConnect.runSqlQuery("SELECT * from sys_adspace WHERE systemclient='wechatsaletool' and isused=1");
 
@@ -211,8 +210,62 @@ public class Store extends Controller {
             detailRow.put("ad_" + adspaceRow.getString("location"), adRows);
         }
 
+        addHistory(sa_storeid);
+
 
         return getSucReturnObject().setData(detailRow).toString();
     }
 
+
+    public void addHistory(Long sa_storeid) throws YosException {
+
+        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_store_history");
+        querySQL.setSiteid(siteid);
+        querySQL.setWhere("userid", userid);
+        querySQL.setWhere("sa_storeid", sa_storeid);
+        Rows rows = querySQL.query();
+        if (rows.isNotEmpty()) {
+            UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, "sa_store_history");
+            updateSQL.setSiteid(siteid);
+            updateSQL.setValue("userid", userid);
+            updateSQL.setWhere("userid", userid);
+            updateSQL.setWhere("sa_storeid", sa_storeid);
+            System.err.println(updateSQL.getSQL());
+            updateSQL.update();
+        } else {
+            InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sa_store_history");
+            insertSQL.setUniqueid(createTableID("sa_store_history"));
+            insertSQL.setSiteid(siteid);
+            insertSQL.setValue("userid", userid);
+            insertSQL.setValue("sa_storeid", sa_storeid);
+            insertSQL.insert();
+        }
+
+    }
+
+
+    @API(title = "查询历史足迹", apiversion = R.ID20240416162002.v1.class)
+    public String getHistory() throws YosException {
+
+        QuerySQL querySQL = SQLFactory.createQuerySQL(controller, "sa_store"
+                        , "sa_storeid", "storename","longitude","latitude")
+                .setTableAlias("t1");
+        querySQL.addJoinTable(JOINTYPE.left, "sys_enterprise_hr", "t2", "t2.sys_enterprise_hrid=t1.leader_hrid and t2.siteid=t1.siteid"
+                , "name","phonenumber");
+        querySQL.addJoinTable(JOINTYPE.inner, "sa_store_history", "t3", "t3.sa_storeid=t1.sa_storeid and t3.siteid=t1.siteid");
+        querySQL.setSiteid(siteid);
+        querySQL.setWhere("t3.userid",userid);
+        querySQL.setPage(pageSize, pageNumber).setOrderBy(pageSorting);
+        Rows rows = querySQL.query();
+
+        RowsMap attinfoRows = Attachment.get(controller, sa_store, rows.toArrayList("sa_storeid", new ArrayList<>()));
+
+        for (Row row:rows) {
+            row.put("attinfos", attinfoRows.getOrDefault(row.getString("sa_storeid"), new Rows()));
+        }
+
+
+        return getSucReturnObject().setData(rows).toString();
+    }
 }
+