|
|
@@ -1498,7 +1498,109 @@ public class Order extends Controller {
|
|
|
|
|
|
return getSucReturnObject().setData(rebateamount).toString();
|
|
|
}
|
|
|
+ @API(title = "一键出库", apiversion = R.ID2025101815441503.v1.class)
|
|
|
+ public String oneClickcreateStockbill() throws YosException {
|
|
|
+ long sa_orderid =content.getLong("sa_orderid");
|
|
|
+ String outplace=content.getString("outplace");
|
|
|
+ JSONArray sa_orderitemsids=content.getJSONArray("sa_orderitemsids");
|
|
|
+ QuerySQL stockbillQuerySQL = SQLFactory.createQuerySQL(this, "st_stockbill_items");
|
|
|
+ stockbillQuerySQL.setTableAlias("t1");
|
|
|
+ stockbillQuerySQL.addJoinTable(JOINTYPE.inner, "st_stockbill", "t2", "t2.st_stockbillid=t1.st_stockbillid and t1.siteid=t2.siteid");
|
|
|
+ stockbillQuerySQL.setWhere("t1.siteid",siteid);
|
|
|
+ stockbillQuerySQL.setWhere("t1.sa_orderitemsid",sa_orderitemsids);
|
|
|
+ Rows stockbillRows =stockbillQuerySQL.query();
|
|
|
+ if(stockbillRows.isNotEmpty()){
|
|
|
+ return getErrReturnObject().setErrMsg("存在订单明细已生成销售出库单,无法一键出库").toString();
|
|
|
+ }
|
|
|
+ Rows rows = getOrderRows(this, sa_orderid);
|
|
|
+ if (rows.isEmpty()) {
|
|
|
+ return getErrReturnObject().setErrMsg("订单不存在").toString();
|
|
|
+ }
|
|
|
+ if(sa_orderitemsids.isEmpty()){
|
|
|
+ return getErrReturnObject().setErrMsg("未选择订单明细,无法一键出库").toString();
|
|
|
+ }
|
|
|
+ if(sa_orderitemsids.isEmpty()){
|
|
|
+ return getErrReturnObject().setErrMsg("未选择订单明细,无法一键出库").toString();
|
|
|
+ }
|
|
|
+ ArrayList<String> sqlList = new ArrayList<>();
|
|
|
+ QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_orderitems","*");
|
|
|
+ stockbillQuerySQL.setTableAlias("t1");
|
|
|
+ stockbillQuerySQL.addJoinTable(JOINTYPE.inner, "plm_item", "t2", "t2.itemid=t1.itemid and t1.siteid=t2.siteid","skucontrol");
|
|
|
+ querySQL.setWhere("t1.siteid",siteid);
|
|
|
+ querySQL.setWhere("t1.sa_orderitemsid",sa_orderitemsids);
|
|
|
+ Rows rowsdetail = querySQL.query();
|
|
|
+ Row orderRow = rows.get(0);
|
|
|
|
|
|
+ long st_stockbillid = createTableID("st_stockbill");
|
|
|
+ InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "st_stockbill");
|
|
|
+ insertSQL.setUniqueid(st_stockbillid);
|
|
|
+ insertSQL.setSiteid(siteid);
|
|
|
+ insertSQL.setValue("sys_enterpriseid", orderRow.getLong("sys_enterpriseid"));
|
|
|
+ insertSQL.setValue("rec_contactsid", orderRow.getLong("rec_contactsid"));
|
|
|
+ insertSQL.setValue("departmentid", 0);
|
|
|
+ insertSQL.setValue("stockid", 0);
|
|
|
+ insertSQL.setValue("type", "销售出库");
|
|
|
+ insertSQL.setValue("typemx", "");
|
|
|
+ insertSQL.setValue("sa_supplierid", 0);
|
|
|
+ insertSQL.setValue("rb", 1);
|
|
|
+ insertSQL.setValue("remarks", "");
|
|
|
+ insertSQL.setDateValue("billdate");
|
|
|
+ insertSQL.setValue("billno", createBillCode("stockbill"));
|
|
|
+
|
|
|
+ insertSQL.setValue("outplace", outplace);
|
|
|
+ insertSQL.setValue("delivery", orderRow.getString("delivery"));
|
|
|
+ insertSQL.setValue("invoice_enterprisename", "");
|
|
|
+ insertSQL.setValue("invoice_address", "");
|
|
|
+ insertSQL.setValue("invoice_taxno", "");
|
|
|
+ insertSQL.setValue("tracknumber", "");
|
|
|
+ insertSQL.setValue("isconfirm", 0);
|
|
|
+
|
|
|
+ insertSQL.setValue("period", getDate_Str().substring(0, 7));
|
|
|
+
|
|
|
+ insertSQL.setValue("createby", username);
|
|
|
+ insertSQL.setDateValue("createdate");
|
|
|
+ insertSQL.setValue("changeby", username);
|
|
|
+ insertSQL.setDateValue("changedate");
|
|
|
+ insertSQL.setValue("status", "新建");
|
|
|
+ insertSQL.setValue("payamount", 0);
|
|
|
+ insertSQL.setValue("paydiscountamount", 0);
|
|
|
+ sqlList.add(insertSQL.getSQL());
|
|
|
+
|
|
|
+ sqlList.add(DataContrlLog.createLog(this, "st_stockbill", st_stockbillid, "新增", "销售出库单新增成功").getSQL());
|
|
|
+
|
|
|
+ int i = 1;
|
|
|
+ BigDecimal payamount =BigDecimal.ZERO;
|
|
|
+ for (Row row : rowsdetail) {
|
|
|
+ payamount=payamount.add(row.getBigDecimal("undeliqty").multiply(row.getBigDecimal("price")));
|
|
|
+ insertSQL = SQLFactory.createInsertSQL(this, "st_stockbill_items");
|
|
|
+ insertSQL.setUniqueid(createTableID("st_stockbill_items"));
|
|
|
+ insertSQL.setSiteid(siteid);
|
|
|
+ insertSQL.setValue("rowno",i);
|
|
|
+ insertSQL.setValue("st_stockbillid", st_stockbillid);
|
|
|
+ insertSQL.setValue("sa_orderitemsid", row.getLong("sa_orderitemsid"));
|
|
|
+ insertSQL.setValue("itemid", row.getLong("itemid"));
|
|
|
+ insertSQL.setValue("sa_orderid", row.getLong("sa_orderid"));
|
|
|
+ insertSQL.setValue("qty", row.getLong("undeliqty"));
|
|
|
+ insertSQL.setValue("discountrate", row.getBigDecimal("discountrate"));
|
|
|
+ insertSQL.setValue("sa_dispatch_itemsid", 0);
|
|
|
+ insertSQL.setValue("defaultprice", row.getBigDecimal("defaultprice"));
|
|
|
+ insertSQL.setValue("remarks", row.getString("remarks"));
|
|
|
+ insertSQL.setValue("itemno", row.getString("itemno"));
|
|
|
+ insertSQL.setValue("itemname", row.getString("itemname"));
|
|
|
+ insertSQL.setValue("model", row.getString("model"));
|
|
|
+ insertSQL.setValue("price", row.getBigDecimal("price"));
|
|
|
+ insertSQL.setValue("amount", row.getBigDecimal("undeliqty").multiply(row.getBigDecimal("price")));
|
|
|
+ insertSQL.setValue("untaxedprice", row.getBigDecimal("price").divide(new BigDecimal(1.13),2, BigDecimal.ROUND_HALF_UP));
|
|
|
+ insertSQL.setValue("untaxedamount", row.getBigDecimal("undeliqty").multiply(row.getBigDecimal("price").divide(new BigDecimal(1.13),2, BigDecimal.ROUND_HALF_UP)));
|
|
|
+ insertSQL.setValue("skucontrol", row.getBoolean("skucontrol"));
|
|
|
+ i++;
|
|
|
+ sqlList.add(insertSQL.getSQL());
|
|
|
+ }
|
|
|
+ dbConnect.runSqlUpdate(sqlList);
|
|
|
+ dbConnect.runSqlUpdate("update st_stockbill set payamount="+payamount+" where st_stockbillid="+st_stockbillid);
|
|
|
+ content.put("st_stockbillid",st_stockbillid);
|
|
|
+ return getSucReturnObject().toString();
|
|
|
+ }
|
|
|
|
|
|
@API(title = "提交", apiversion = R.ID20221108153402.v1.class, intervaltime = 5000)
|
|
|
@CACHEING_CLEAN(apiClass = {Order.class, OrderItems.class, restcontroller.sale.order.Order.class, cashbill.class, promotion.class, restcontroller.webmanage.sale.promotion.promotion.class, accessoryorder.class})
|
|
|
@@ -2947,6 +3049,9 @@ public class Order extends Controller {
|
|
|
return getSucReturnObject().setData(rows).toString();
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
@API(title = "查询订单进度", apiversion = R.ID20221229093602.v1.class)
|
|
|
@CACHEING
|
|
|
public String getOrderProcess() throws YosException {
|