|
|
@@ -8,12 +8,13 @@ import common.YosException;
|
|
|
import common.annotation.API;
|
|
|
import common.data.*;
|
|
|
import io.swagger.annotations.Api;
|
|
|
+import org.apache.camel.json.simple.Jsonable;
|
|
|
import restcontroller.R;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
/**
|
|
|
- * 订单费用计算方案
|
|
|
+ * 定制费用方案
|
|
|
*/
|
|
|
public class OrderFeeCostPlan extends Controller {
|
|
|
/**
|
|
|
@@ -25,55 +26,83 @@ public class OrderFeeCostPlan extends Controller {
|
|
|
super(content);
|
|
|
}
|
|
|
|
|
|
- @API(title = "查询可选定制方案列表", apiversion = R.ID20231208133902.v1.class)
|
|
|
+ @API(title = "定制费用方案-列表", apiversion = R.ID20231208133902.v1.class)
|
|
|
public String customPlanList() throws YosException {
|
|
|
QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sys_datafunction",
|
|
|
- "sys_datafunctionid", "functionname", "remarks", "isused", "createdate");
|
|
|
+ "sys_datafunctionid", "functionname", "remarks", "createdate");
|
|
|
//创建人写死admin
|
|
|
querySQL.addQueryFields("createby", "\'admin\'");
|
|
|
querySQL.setWhere("t1.functionclass", "ordercost");
|
|
|
+ querySQL.setWhere("t1.sys_datafunctionid in (SELECT sys_datafunctionid from sys_datafunction_params WHERE param='siteid' and value='" + siteid + "')");
|
|
|
querySQL.setPage(pageSize, pageNumber).setOrderBy(pageSorting).setTableAlias("t1");
|
|
|
Rows rows = querySQL.query();
|
|
|
-
|
|
|
return getSucReturnObject().setData(rows).toString();
|
|
|
}
|
|
|
|
|
|
- @API(title = "绑定定制方案", apiversion = R.ID20231208134002.v1.class)
|
|
|
+ @API(title = "定制费用方案-绑定", apiversion = R.ID20231208134002.v1.class)
|
|
|
public String insertOrUpdatePlan() throws YosException {
|
|
|
|
|
|
Long sys_datafunctionid = content.getLongValue("sys_datafunctionid");
|
|
|
- Long ownerid = content.getLongValue("ownerid");
|
|
|
- String ownertable = content.getStringValue("ownertable");
|
|
|
-
|
|
|
- Rows rows = dbConnect.runSqlQuery("SELECT * from sys_datafunction_bind WHERE ownerid=" + ownerid + " and ownertable='" + ownertable + "'");
|
|
|
- if (rows.isEmpty()) {
|
|
|
- InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sys_datafunction_bind");
|
|
|
- insertSQL.setUniqueid(createTableID("sys_datafunction_bind"));
|
|
|
- insertSQL.setValue("ownerid", ownerid);
|
|
|
- insertSQL.setValue("ownertable", ownertable);
|
|
|
- insertSQL.setValue("sys_datafunctionid", sys_datafunctionid);
|
|
|
- insertSQL.insert();
|
|
|
- } else {
|
|
|
- UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, "sys_datafunction_bind");
|
|
|
- updateSQL.setUniqueid(rows.get(0).getLong("sys_datafunction_bindid"));
|
|
|
- updateSQL.setValue("sys_datafunctionid", sys_datafunctionid);
|
|
|
- updateSQL.update();
|
|
|
+ JSONArray items = content.getJSONArray("items");
|
|
|
+ ArrayList<String> sqlList = new ArrayList<>();
|
|
|
+ for (Object obj : items) {
|
|
|
+ JSONObject item = (JSONObject) obj;
|
|
|
+ Long ownerid = item.getLongValue("ownerid");
|
|
|
+ String ownertable = item.getStringValue("ownertable");
|
|
|
+ Rows rows = dbConnect.runSqlQuery("SELECT * from sys_datafunction_bind WHERE ownerid=" + ownerid + " and ownertable='" + ownertable + "'");
|
|
|
+ if (rows.isEmpty()) {
|
|
|
+ InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sys_datafunction_bind");
|
|
|
+ insertSQL.setUniqueid(createTableID("sys_datafunction_bind"));
|
|
|
+ insertSQL.setValue("ownerid", ownerid);
|
|
|
+ insertSQL.setValue("ownertable", ownertable);
|
|
|
+ insertSQL.setValue("sys_datafunctionid", sys_datafunctionid);
|
|
|
+ sqlList.add(insertSQL.getSQL());
|
|
|
+ } else {
|
|
|
+ UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, "sys_datafunction_bind");
|
|
|
+ updateSQL.setUniqueid(rows.get(0).getLong("sys_datafunction_bindid"));
|
|
|
+ updateSQL.setValue("sys_datafunctionid", sys_datafunctionid);
|
|
|
+ sqlList.add(updateSQL.getSQL());
|
|
|
+ }
|
|
|
}
|
|
|
+ dbConnect.runSqlUpdate(sqlList);
|
|
|
|
|
|
|
|
|
return getSucReturnObject().toString();
|
|
|
}
|
|
|
|
|
|
- @API(title = "删除商品定制方案", apiversion = R.ID20231208134102.v1.class)
|
|
|
+ @API(title = "定制费用方案-商品列表", apiversion = R.ID20231212110202.v1.class)
|
|
|
+ public String bindItemList() throws YosException {
|
|
|
+ Long sys_datafunctionid = content.getLongValue("sys_datafunctionid");
|
|
|
+
|
|
|
+ QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sys_datafunction_bind");
|
|
|
+ querySQL.addJoinTable(JOINTYPE.inner, "plm_item", "t2", "t1.ownerid=t2.itemid and t1.ownertable='plm_item'"
|
|
|
+ , "itemname");
|
|
|
+ //创建人写死admin
|
|
|
+ querySQL.setWhere("t1.sys_datafunctionid", sys_datafunctionid);
|
|
|
+ querySQL.setPage(pageSize, pageNumber).setOrderBy(pageSorting).setTableAlias("t1");
|
|
|
+ Rows rows = querySQL.query();
|
|
|
+ return getSucReturnObject().setData(rows).toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "定制费用方案-参数列表", apiversion = R.ID20231212111202.v1.class)
|
|
|
+ public String queryParam() throws YosException {
|
|
|
+ Long sys_datafunctionid = content.getLongValue("sys_datafunctionid");
|
|
|
+ Rows paramRows = dbConnect.runSqlQuery("SELECT * from sys_datafunction_params WHERE param!='siteid' and sys_datafunctionid=" + sys_datafunctionid);
|
|
|
+ return getSucReturnObject().setData(paramRows).toString();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @API(title = "定制费用方案-删除绑定商品", apiversion = R.ID20231208134102.v1.class)
|
|
|
public String delete() throws YosException {
|
|
|
- Long sys_datafunction_bindid = content.getLongValue("sys_datafunction_bindid");
|
|
|
+ JSONArray sys_datafunction_bindids = content.getJSONArray("sys_datafunction_bindids");
|
|
|
+
|
|
|
DeleteSQL deleteSQL = SQLFactory.createDeleteSQL(this, "sys_datafunction_bind");
|
|
|
- deleteSQL.setUniqueid(sys_datafunction_bindid);
|
|
|
+ deleteSQL.setWhere("sys_datafunction_bindid", sys_datafunction_bindids.toArray());
|
|
|
deleteSQL.delete();
|
|
|
return getSucReturnObject().toString();
|
|
|
}
|
|
|
|
|
|
- @API(title = "商品定制方案列表", apiversion = R.ID20231208134202.v1.class)
|
|
|
+ @API(title = "商品定制费用方案详情", apiversion = R.ID20231208134202.v1.class)
|
|
|
public String list() throws YosException {
|
|
|
Long ownerid = content.getLongValue("ownerid");
|
|
|
String ownertable = content.getStringValue("ownertable");
|
|
|
@@ -101,7 +130,7 @@ public class OrderFeeCostPlan extends Controller {
|
|
|
}
|
|
|
|
|
|
|
|
|
- @API(title = "修改参数值", apiversion = R.ID20231211141802.v1.class)
|
|
|
+ @API(title = "定制费用方案-调整参数值", apiversion = R.ID20231211141802.v1.class)
|
|
|
public String modifyFunctionParams() throws YosException {
|
|
|
|
|
|
JSONArray items = content.getJSONArray("items");
|