|
@@ -0,0 +1,143 @@
|
|
|
+package restcontroller.webmanage.saletool.custorder;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import common.Controller;
|
|
|
+import common.YosException;
|
|
|
+import common.annotation.API;
|
|
|
+import common.data.*;
|
|
|
+import restcontroller.R;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 收货地址
|
|
|
+ */
|
|
|
+public class DeliveryAddress extends Controller {
|
|
|
+ /**
|
|
|
+ * 构造函数
|
|
|
+ *
|
|
|
+ * @param content
|
|
|
+ */
|
|
|
+ public DeliveryAddress(JSONObject content) throws YosException {
|
|
|
+ super(content);
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "收货地址新增或编辑", apiversion = R.ID20240506103402.v1.class)
|
|
|
+ public String insertOrUpdate() throws YosException {
|
|
|
+
|
|
|
+ Long contactsid = content.getLongValue("contactsid");
|
|
|
+
|
|
|
+ if (contactsid <= 0) {
|
|
|
+ contactsid = createTableID("sys_enterprise_contacts");
|
|
|
+ InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sys_enterprise_contacts");
|
|
|
+ insertSQL.setSiteid(siteid);
|
|
|
+ insertSQL.setUniqueid(contactsid);
|
|
|
+ insertSQL.setValue("name", content.getStringValue("name"));
|
|
|
+ insertSQL.setValue("phonenumber", content.getStringValue("phonenumber"));
|
|
|
+ insertSQL.setValue("isdefault", content.getBooleanValue("isdefault"));
|
|
|
+ insertSQL.setValue("province", content.getStringValue("province"));
|
|
|
+ insertSQL.setValue("city", content.getStringValue("city"));
|
|
|
+ insertSQL.setValue("county", content.getStringValue("county"));
|
|
|
+ insertSQL.setValue("address", content.getStringValue("address"));
|
|
|
+ insertSQL.setValue("workaddress", 0);
|
|
|
+ insertSQL.insert();
|
|
|
+
|
|
|
+ } else {
|
|
|
+ UpdateSQL insertSQL = SQLFactory.createUpdateSQL(this, "sys_enterprise_contacts");
|
|
|
+ insertSQL.setSiteid(siteid);
|
|
|
+ insertSQL.setUniqueid(contactsid);
|
|
|
+ insertSQL.setValue("name", content.getStringValue("name"));
|
|
|
+ insertSQL.setValue("phonenumber", content.getStringValue("phonenumber"));
|
|
|
+ insertSQL.setValue("isdefault", content.getBooleanValue("isdefault"));
|
|
|
+ insertSQL.setValue("province", content.getStringValue("province"));
|
|
|
+ insertSQL.setValue("city", content.getStringValue("city"));
|
|
|
+ insertSQL.setValue("county", content.getStringValue("county"));
|
|
|
+ insertSQL.setValue("address", content.getStringValue("address"));
|
|
|
+ insertSQL.setValue("workaddress", 0);
|
|
|
+ insertSQL.update();
|
|
|
+ }
|
|
|
+ if (content.getBooleanValue("isdefault")) {
|
|
|
+ UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, "sys_enterprise_contacts");
|
|
|
+ updateSQL.setSiteid(siteid);
|
|
|
+ updateSQL.setWhere("createuserid", userid);
|
|
|
+ updateSQL.setValue("isdefault", 0);
|
|
|
+ updateSQL.update();
|
|
|
+
|
|
|
+ updateSQL = SQLFactory.createUpdateSQL(this, "sys_enterprise_contacts");
|
|
|
+ updateSQL.setSiteid(siteid);
|
|
|
+ updateSQL.setWhere("contactsid", contactsid);
|
|
|
+ updateSQL.setValue("isdefault", 1);
|
|
|
+ updateSQL.update();
|
|
|
+ }
|
|
|
+
|
|
|
+ Rows rows = dbConnect.runSqlQuery("SELECT * from sys_enterprise_contacts where contactsid='" + contactsid + "' and siteid='" + siteid + "'");
|
|
|
+
|
|
|
+
|
|
|
+ return getSucReturnObject().setData(rows.get(0)).toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "删除", apiversion = R.ID20240506103502.v1.class)
|
|
|
+ public String delete() throws YosException {
|
|
|
+
|
|
|
+ JSONArray contactsids = content.getJSONArray("contactsids");
|
|
|
+
|
|
|
+ UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, "sys_enterprise_contacts");
|
|
|
+ updateSQL.setSiteid(siteid);
|
|
|
+ updateSQL.setWhere("contactsid", contactsids);
|
|
|
+ updateSQL.setValue("deleted", 1);
|
|
|
+ updateSQL.update();
|
|
|
+
|
|
|
+
|
|
|
+ return getSucReturnObject().toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "收货地址默认", apiversion = R.ID20240506103602.v1.class)
|
|
|
+ public String isdefault() throws YosException {
|
|
|
+
|
|
|
+ Long contactsid = content.getLongValue("contactsid");
|
|
|
+ UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, "sys_enterprise_contacts");
|
|
|
+ updateSQL.setSiteid(siteid);
|
|
|
+ updateSQL.setWhere("createuserid", userid);
|
|
|
+ updateSQL.setValue("isdefault", 0);
|
|
|
+ updateSQL.update();
|
|
|
+
|
|
|
+ updateSQL = SQLFactory.createUpdateSQL(this, "sys_enterprise_contacts");
|
|
|
+ updateSQL.setSiteid(siteid);
|
|
|
+ updateSQL.setWhere("contactsid", contactsid);
|
|
|
+ updateSQL.setValue("isdefault", 1);
|
|
|
+ updateSQL.update();
|
|
|
+
|
|
|
+ return getSucReturnObject().toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "收货地址列表", apiversion = R.ID20240506103702.v1.class)
|
|
|
+ public String list() throws YosException {
|
|
|
+
|
|
|
+ StringBuffer where = new StringBuffer(" 1=1 ");
|
|
|
+ if (content.containsKey("where")) {
|
|
|
+ JSONObject whereObject = content.getJSONObject("where");
|
|
|
+ if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
|
|
|
+ where.append(" and (");
|
|
|
+ where.append("t1.name like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append("or t1.phonenumber like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append("or t1.province like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append("or t1.city like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append("or t1.county like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append("or t1.address like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append(")");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sys_enterprise_contacts").setTableAlias("t1");
|
|
|
+ querySQL.setSiteid(siteid);
|
|
|
+ querySQL.setWhere("deleted", 0);
|
|
|
+ querySQL.setWhere(where.toString());
|
|
|
+ querySQL.setWhere("createuserid", userid);
|
|
|
+ querySQL.setPage(pageSize, pageNumber).setOrderBy(pageSorting);
|
|
|
+ Rows rows = querySQL.query();
|
|
|
+
|
|
|
+
|
|
|
+ return getSucReturnObject().setData(rows).toString();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|