|
|
@@ -0,0 +1,70 @@
|
|
|
+package common.md;
|
|
|
+
|
|
|
+import com.alibaba.fastjson2.JSONArray;
|
|
|
+import com.alibaba.fastjson2.JSONObject;
|
|
|
+import common.data.*;
|
|
|
+import common.data.db.DBConnect;
|
|
|
+import org.springframework.stereotype.Controller;
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
+import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
+
|
|
|
+@Controller
|
|
|
+@RequestMapping("/rest/callcenter")
|
|
|
+public class callcenter {
|
|
|
+
|
|
|
+ @RequestMapping("/getcustmsg")
|
|
|
+ @GetMapping
|
|
|
+ @ResponseBody
|
|
|
+ public Object getcustmsg(@RequestParam("phonenumber") String phonenumber) {
|
|
|
+ JSONArray array = new JSONArray();
|
|
|
+ try {
|
|
|
+ QuerySQL querySQL = SQLFactory.createQuerySQL(new DBConnect(), "sa_warrantycard").setTableAlias("t1");
|
|
|
+ querySQL.addJoinTable(QuerySQL.JOINTYPE.left, "plm_item", "t2", "itemid=:itemid",
|
|
|
+ "itemno", "itemname", "model", "spec");
|
|
|
+ Rows rows = querySQL.setWhere("phonenumber", phonenumber).query();
|
|
|
+ if (rows.size() < 50) {
|
|
|
+ QuerySQL agentsQuery = SQLFactory.createQuerySQL(new DBConnect(), "sa_agents", "agentnum", "sys_enterpriseid").setTableAlias("t1");
|
|
|
+ agentsQuery.addJoinTable(QuerySQL.JOINTYPE.left, "sys_enterprise", "t2", "sys_enterpriseid=:sys_enterpriseid",
|
|
|
+ "enterprisename", "province", "city", "county");
|
|
|
+ agentsQuery.setWhere("t1.sys_enterpriseid", rows.toArrayList("sys_enterpriseid"));
|
|
|
+ RowsMap agentRowsMap = agentsQuery.query().toRowsMap("sys_enterpriseid");
|
|
|
+
|
|
|
+ for (Row row : rows) {
|
|
|
+ JSONObject object = new JSONObject();
|
|
|
+ object.put("twarrantycardid", row.getString("sa_warrantycardid"));
|
|
|
+ object.put("fname", row.getString("name"));
|
|
|
+ object.put("fsex", row.getString("sex"));
|
|
|
+ object.put("fphonenumber", row.getString("phonenumber"));
|
|
|
+ object.put("fitemno", row.getString("itemno"));
|
|
|
+ object.put("fitemname", row.getString("itemname"));
|
|
|
+ object.put("fmodel", row.getString("model"));
|
|
|
+ object.put("fspec", row.getString("spec"));
|
|
|
+ object.put("fmachinecode", row.getString("sku"));
|
|
|
+ object.put("fbegdate", row.getString("begdate"));
|
|
|
+ object.put("fenddate", row.getString("enddate"));
|
|
|
+ object.put("faddress", row.getString("address"));
|
|
|
+
|
|
|
+ if (agentRowsMap.containsKey(row.getString("sys_enterpriseid"))) {
|
|
|
+ Row agentRow = agentRowsMap.get(row.getString("sys_enterpriseid")).get(0);
|
|
|
+ object.put("fagentnum", agentRow.getString("agentnum"));
|
|
|
+ object.put("fagentname", agentRow.getString("enterprisename"));
|
|
|
+ object.put("fprovince", agentRow.getString("province"));
|
|
|
+ object.put("fcity", agentRow.getString("city"));
|
|
|
+ object.put("fcounty", agentRow.getString("county"));
|
|
|
+ } else {
|
|
|
+ object.put("fagentname", "");
|
|
|
+ object.put("fprovince", "");
|
|
|
+ object.put("fcity", "");
|
|
|
+ object.put("fcounty", "");
|
|
|
+ }
|
|
|
+ array.add(object);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return array;
|
|
|
+ }
|
|
|
+}
|