|
@@ -225,63 +225,70 @@ public class stockbill extends Controller {
|
|
|
|
|
|
|
|
@API(title = "美大CRM_经销商_出入库单商品明细新增修改", apiversion = R.ID2026031716051401.v1.class, params = {
|
|
@API(title = "美大CRM_经销商_出入库单商品明细新增修改", apiversion = R.ID2026031716051401.v1.class, params = {
|
|
|
@Param(paramname = "sys_enterprise_stockbillid", fieldtype = FieldType.BigInt, remarks = "企业出入库单ID", isrequired = true),
|
|
@Param(paramname = "sys_enterprise_stockbillid", fieldtype = FieldType.BigInt, remarks = "企业出入库单ID", isrequired = true),
|
|
|
- @Param(paramname = "sys_enterprise_stockbill_itemsid", fieldtype = FieldType.BigInt, remarks = "企业出入库单货品明细", isrequired = true),
|
|
|
|
|
|
|
+ @Param(paramname = "sys_enterprise_stockbill_items", fieldtype = FieldType.JSON, remarks = "企业出入库单货品明细,明细字段均放在该对象下", isrequired = true),
|
|
|
|
|
+ @Param(paramname = "sys_enterprise_stockbill_itemsid", fieldtype = FieldType.BigInt, remarks = "企业出入库单货品明细id", isrequired = true),
|
|
|
@Param(paramname = "sa_custorderitemsid", fieldtype = FieldType.BigInt, remarks = "C端订单商品表ID"),
|
|
@Param(paramname = "sa_custorderitemsid", fieldtype = FieldType.BigInt, remarks = "C端订单商品表ID"),
|
|
|
@Param(paramname = "sys_enterprise_itemid", fieldtype = FieldType.BigInt, remarks = "企业商品档案表ID", isrequired = true),
|
|
@Param(paramname = "sys_enterprise_itemid", fieldtype = FieldType.BigInt, remarks = "企业商品档案表ID", isrequired = true),
|
|
|
@Param(paramname = "qty", fieldtype = FieldType.Decimal, remarks = "数量", isrequired = true),
|
|
@Param(paramname = "qty", fieldtype = FieldType.Decimal, remarks = "数量", isrequired = true),
|
|
|
@Param(paramname = "remarks", fieldtype = FieldType.Varchar, remarks = "备注说明")})
|
|
@Param(paramname = "remarks", fieldtype = FieldType.Varchar, remarks = "备注说明")})
|
|
|
public String sys_enterprise_stockbill_items_save() throws YosException {
|
|
public String sys_enterprise_stockbill_items_save() throws YosException {
|
|
|
long sys_enterprise_stockbillid = content.getLong("sys_enterprise_stockbillid");// 企业出入库单ID
|
|
long sys_enterprise_stockbillid = content.getLong("sys_enterprise_stockbillid");// 企业出入库单ID
|
|
|
- long sys_enterprise_stockbill_itemsid = content.getLongValue("sys_enterprise_stockbill_itemsid");
|
|
|
|
|
- long sa_custorderitemsid = content.getLongValue("sa_custorderitemsid");// C端订单商品表ID
|
|
|
|
|
- long sys_enterprise_itemid = content.getLongValue("sys_enterprise_itemid");// 企业商品档案表ID
|
|
|
|
|
- double qty = content.getDoubleValue("qty");// 数量
|
|
|
|
|
- String remarks = content.getStringValue("remarks");// 备注说明
|
|
|
|
|
|
|
+ JSONArray sys_enterprise_stockbill_items = content.getJSONArray("sys_enterprise_stockbill_items");
|
|
|
|
|
|
|
|
if (!getBillStatus(sys_enterprise_stockbillid).equals("新建")) {
|
|
if (!getBillStatus(sys_enterprise_stockbillid).equals("新建")) {
|
|
|
return getErrReturnObject().setErrMsg("当前单据不是新建状态,不能修改").toString();
|
|
return getErrReturnObject().setErrMsg("当前单据不是新建状态,不能修改").toString();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
SQLDump sqldump = new SQLDump();
|
|
SQLDump sqldump = new SQLDump();
|
|
|
- if (sys_enterprise_stockbill_itemsid <= 0 || SQLFactory.createQuerySQL(this, "sys_enterprise_stockbill_items", "sys_enterprise_stockbill_itemsid").setSiteid(siteid).setUniqueid(sys_enterprise_stockbill_itemsid).query().isEmpty()) {
|
|
|
|
|
- sys_enterprise_stockbill_itemsid = createTableID("sys_enterprise_stockbill_items");
|
|
|
|
|
- InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sys_enterprise_stockbill_items");
|
|
|
|
|
- insertSQL.setValue("siteid", siteid);// 站点
|
|
|
|
|
- insertSQL.setValue("sys_enterpriseid", sys_enterpriseid);// 合作企业档案ID
|
|
|
|
|
- insertSQL.setValue("sys_enterprise_stockbillid", sys_enterprise_stockbillid);// 企业出入库单ID
|
|
|
|
|
- insertSQL.setValue("sa_custorderitemsid", sa_custorderitemsid);// C端订单商品表ID
|
|
|
|
|
- insertSQL.setValue("sys_enterprise_itemid", sys_enterprise_itemid);// 企业商品档案表ID
|
|
|
|
|
- insertSQL.setValue("hongqty", 0);// 已红冲数量
|
|
|
|
|
- insertSQL.setValue("remarks", remarks);// 备注说明
|
|
|
|
|
-
|
|
|
|
|
- QuerySQL itemQuery = SQLFactory.createQuerySQL(this, "sys_enterprise_item");
|
|
|
|
|
- itemQuery.setWhere("sys_enterprise_itemid", sys_enterprise_itemid);
|
|
|
|
|
- itemQuery.setWhere("sys_enterpriseid", sys_enterpriseid);
|
|
|
|
|
- itemQuery.setWhere("siteid", siteid);
|
|
|
|
|
-
|
|
|
|
|
- Rows itemrow = itemQuery.query();
|
|
|
|
|
- if (itemrow.isEmpty()) {
|
|
|
|
|
- return getErrReturnObject().setErrMsg("商品档案不存在").toString();
|
|
|
|
|
|
|
+ for (int i = 0; i < sys_enterprise_stockbill_items.size(); i++) {
|
|
|
|
|
+ JSONObject itemObject = sys_enterprise_stockbill_items.getJSONObject(i);
|
|
|
|
|
+
|
|
|
|
|
+ long sys_enterprise_stockbill_itemsid = itemObject.getLongValue("sys_enterprise_stockbill_itemsid");
|
|
|
|
|
+ long sa_custorderitemsid = itemObject.getLongValue("sa_custorderitemsid");// C端订单商品表ID
|
|
|
|
|
+ long sys_enterprise_itemid = itemObject.getLongValue("sys_enterprise_itemid");// 企业商品档案表ID
|
|
|
|
|
+ double qty = itemObject.getDoubleValue("qty");// 数量
|
|
|
|
|
+ String remarks = itemObject.getStringValue("remarks");// 备注说明
|
|
|
|
|
+
|
|
|
|
|
+ if (sys_enterprise_stockbill_itemsid <= 0 || SQLFactory.createQuerySQL(this, "sys_enterprise_stockbill_items", "sys_enterprise_stockbill_itemsid").setSiteid(siteid).setUniqueid(sys_enterprise_stockbill_itemsid).query().isEmpty()) {
|
|
|
|
|
+ sys_enterprise_stockbill_itemsid = createTableID("sys_enterprise_stockbill_items");
|
|
|
|
|
+ InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sys_enterprise_stockbill_items");
|
|
|
|
|
+ insertSQL.setValue("siteid", siteid);// 站点
|
|
|
|
|
+ insertSQL.setValue("sys_enterpriseid", sys_enterpriseid);// 合作企业档案ID
|
|
|
|
|
+ insertSQL.setValue("sys_enterprise_stockbillid", sys_enterprise_stockbillid);// 企业出入库单ID
|
|
|
|
|
+ insertSQL.setValue("sa_custorderitemsid", sa_custorderitemsid);// C端订单商品表ID
|
|
|
|
|
+ insertSQL.setValue("sys_enterprise_itemid", sys_enterprise_itemid);// 企业商品档案表ID
|
|
|
|
|
+ insertSQL.setValue("hongqty", 0);// 已红冲数量
|
|
|
|
|
+ insertSQL.setValue("remarks", remarks);// 备注说明
|
|
|
|
|
+
|
|
|
|
|
+ QuerySQL itemQuery = SQLFactory.createQuerySQL(this, "sys_enterprise_item");
|
|
|
|
|
+ itemQuery.setWhere("sys_enterprise_itemid", sys_enterprise_itemid);
|
|
|
|
|
+ itemQuery.setWhere("sys_enterpriseid", sys_enterpriseid);
|
|
|
|
|
+ itemQuery.setWhere("siteid", siteid);
|
|
|
|
|
+
|
|
|
|
|
+ Rows itemrow = itemQuery.query();
|
|
|
|
|
+ if (itemrow.isEmpty()) {
|
|
|
|
|
+ return getErrReturnObject().setErrMsg("商品档案不存在").toString();
|
|
|
|
|
+ }
|
|
|
|
|
+ insertSQL.setValue("itemno", itemrow.get(0).getString("itemno"));// 产品编号
|
|
|
|
|
+ insertSQL.setValue("model", itemrow.get(0).getString("model"));// 型号
|
|
|
|
|
+ insertSQL.setValue("itemname", itemrow.get(0).getString("itemname"));// 产品名称
|
|
|
|
|
+ insertSQL.setValue("skucontrol", itemrow.get(0).getBoolean("skucontrol"));// 是否单品管理
|
|
|
|
|
+ insertSQL.setValue("qty", qty);// 数量
|
|
|
|
|
+ insertSQL.setUniqueid(sys_enterprise_stockbill_itemsid);
|
|
|
|
|
+ sqldump.add(insertSQL);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, "sys_enterprise_stockbill_items");
|
|
|
|
|
+ updateSQL.setValue("remarks", remarks);// 备注说明
|
|
|
|
|
+ updateSQL.setValue("qty", qty);// 数量
|
|
|
|
|
+ updateSQL.setSiteid(siteid);
|
|
|
|
|
+ updateSQL.setUniqueid(sys_enterprise_stockbill_itemsid);
|
|
|
|
|
+ updateSQL.setWhere("sys_enterprise_stockbillid", sys_enterprise_stockbillid);// 企业出入库单ID
|
|
|
|
|
+ sqldump.add(updateSQL);
|
|
|
}
|
|
}
|
|
|
- insertSQL.setValue("itemno", itemrow.get(0).getString("itemno"));// 产品编号
|
|
|
|
|
- insertSQL.setValue("model", itemrow.get(0).getString("model"));// 型号
|
|
|
|
|
- insertSQL.setValue("itemname", itemrow.get(0).getString("itemname"));// 产品名称
|
|
|
|
|
- insertSQL.setValue("skucontrol", itemrow.get(0).getBoolean("skucontrol"));// 是否单品管理
|
|
|
|
|
- insertSQL.setValue("qty", qty);// 数量
|
|
|
|
|
- insertSQL.setUniqueid(sys_enterprise_stockbill_itemsid);
|
|
|
|
|
- sqldump.add(insertSQL);
|
|
|
|
|
- } else {
|
|
|
|
|
- UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, "sys_enterprise_stockbill_items");
|
|
|
|
|
- updateSQL.setValue("remarks", remarks);// 备注说明
|
|
|
|
|
- updateSQL.setValue("qty", qty);// 数量
|
|
|
|
|
- updateSQL.setSiteid(siteid);
|
|
|
|
|
- updateSQL.setUniqueid(sys_enterprise_stockbill_itemsid);
|
|
|
|
|
- updateSQL.setWhere("sys_enterprise_stockbillid", sys_enterprise_stockbillid);// 企业出入库单ID
|
|
|
|
|
- sqldump.add(updateSQL);
|
|
|
|
|
}
|
|
}
|
|
|
sqldump.commit();
|
|
sqldump.commit();
|
|
|
updateRowno(sys_enterprise_stockbillid);
|
|
updateRowno(sys_enterprise_stockbillid);
|
|
|
- return getSucReturnObject().setData(sys_enterprise_stockbill_itemsid).toString();
|
|
|
|
|
|
|
+ return getSucReturnObject().toString();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@API(title = "美大CRM_经销商_出入库单商品明细删除", apiversion = R.ID2026031716132201.v1.class, params = {
|
|
@API(title = "美大CRM_经销商_出入库单商品明细删除", apiversion = R.ID2026031716132201.v1.class, params = {
|