|
@@ -180,24 +180,33 @@ public class Store extends Controller {
|
|
|
|
|
|
String longitude = content.getStringValue("longitude");
|
|
|
String latitude = content.getStringValue("latitude");
|
|
|
+ Long sa_storeid = content.getLongValue("sa_storeid");
|
|
|
+ Rows rows;
|
|
|
+
|
|
|
+ if(sa_storeid>0){
|
|
|
+ rows = StoreHelper.queryStores(this,sa_storeid, longitude, latitude);
|
|
|
+ }else {
|
|
|
+ if (usertype == 21 || usertype == 22) {
|
|
|
+ Long sys_enterprise_hrid = getEnterpriseHr(userid).getLong("sys_enterprise_hrid");
|
|
|
+ rows = StoreHelper.queryAgentsStores(this, sys_enterprise_hrid, longitude, latitude);
|
|
|
+ if (rows.isEmpty()) {
|
|
|
+ rows = StoreHelper.queryStores(this, longitude, latitude);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ rows = StoreHelper.queryStores(this, longitude, 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","phonenumber","userid");
|
|
|
- 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("headpic",getHeadPic(detailRow.getLong("userid")));
|
|
|
-
|
|
|
- addHistory(sa_storeid);
|
|
|
+ for (Row row : rows) {
|
|
|
+ row.put("distance", String.format("%.2f", row.getDouble("distance")));
|
|
|
+ row.put("attinfos", Attachment.get(this, "sa_store", row.getLong("sa_storeid")));
|
|
|
+ row.put("headpic", getHeadPic(row.getLong("userid")));
|
|
|
+ addHistory(row.getLong("sa_storeid"));
|
|
|
+ }
|
|
|
|
|
|
|
|
|
- return getSucReturnObject().setData(detailRow).toString();
|
|
|
+ return getSucReturnObject().setData(rows).toString();
|
|
|
}
|
|
|
|
|
|
|
|
@@ -237,20 +246,20 @@ public class Store extends Controller {
|
|
|
QuerySQL querySQL = SQLFactory.createQuerySQL(controller, "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","phonenumber","userid");
|
|
|
+ , "name", "phonenumber", "userid");
|
|
|
querySQL.addJoinTable(JOINTYPE.inner, "sa_store_history", "t3", "t3.sa_storeid=t1.sa_storeid and t3.siteid=t1.siteid");
|
|
|
querySQL.addQueryFields("distance", "st_distance_sphere(point(longitude,latitude),point('" + longitude + "','" + latitude + "'))");
|
|
|
querySQL.setSiteid(siteid);
|
|
|
- querySQL.setWhere("t3.userid",userid);
|
|
|
+ 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) {
|
|
|
+ for (Row row : rows) {
|
|
|
row.put("attinfos", attinfoRows.getOrDefault(row.getString("sa_storeid"), new Rows()));
|
|
|
row.put("distance", String.format("%.2f", row.getDouble("distance")));
|
|
|
- row.put("headpic",getHeadPic(row.getLong("userid")));
|
|
|
+ row.put("headpic", getHeadPic(row.getLong("userid")));
|
|
|
}
|
|
|
|
|
|
|