|
|
@@ -74,13 +74,13 @@ public class OrderItems extends Controller {
|
|
|
|
|
|
Rows itemRows = dbConnect.runSqlQuery("select itemid,orderaddqty,orderminqty,itemno from plm_item where siteid='" + siteid + "'");
|
|
|
RowsMap itemRowsMap = itemRows.toRowsMap("itemid");
|
|
|
- BigDecimal sumqty=BigDecimal.ZERO;
|
|
|
+ BigDecimal sumqty = BigDecimal.ZERO;
|
|
|
for (Object obj : items) {
|
|
|
JSONObject item = (JSONObject) obj;
|
|
|
Long itemid = item.getLong("itemid");
|
|
|
Long sa_orderitemsid = item.getLong("sa_orderitemsid");
|
|
|
BigDecimal qty = item.getBigDecimalValue("qty");
|
|
|
- sumqty=sumqty.add(qty);
|
|
|
+ sumqty = sumqty.add(qty);
|
|
|
if (!type.equals("促销订单")) {
|
|
|
if (itemRowsMap.containsKey(item.getString("itemid"))) {
|
|
|
if (itemRowsMap.get(item.getString("itemid")).isNotEmpty()) {
|
|
|
@@ -124,11 +124,11 @@ public class OrderItems extends Controller {
|
|
|
if (rows.isEmpty()) {
|
|
|
sa_orderitemsid = createTableID("sa_orderitems");
|
|
|
} else {
|
|
|
- System.out.println(beans.order.Order.getDefaultIsRepeatValue(siteid, type));
|
|
|
- if(beans.order.Order.getDefaultIsRepeatValue(siteid, type)){
|
|
|
+ System.out.println(beans.order.Order.getDefaultIsRepeatValue(siteid, type));
|
|
|
+ if (beans.order.Order.getDefaultIsRepeatValue(siteid, type)) {
|
|
|
sa_orderitemsid = createTableID("sa_orderitems");
|
|
|
sqlFactory = new SQLFactory(this, "订单商品明细_新增");
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
price1 = rows.get(0).getBigDecimal("price");
|
|
|
sa_orderitemsid = rows.get(0).getLong("sa_orderitemsid");
|
|
|
sqlFactory = new SQLFactory(this, "订单商品明细_更新");
|
|
|
@@ -217,7 +217,7 @@ public class OrderItems extends Controller {
|
|
|
//折前金额(元)
|
|
|
sqlFactory.addParameter("amount", price.multiply(qty));
|
|
|
} else if (item.getBigDecimalValue("price").compareTo(BigDecimal.ZERO) <= 0 && item.getBigDecimalValue("amount").compareTo(BigDecimal.ZERO) > 0) {
|
|
|
- sqlFactory.addParameter("price", (item.getBigDecimalValue("amount").divide(qty)).setScale(6, BigDecimal.ROUND_HALF_UP));
|
|
|
+ sqlFactory.addParameter("price", item.getBigDecimalValue("amount").divide(qty, 6, BigDecimal.ROUND_HALF_UP));
|
|
|
//折前金额(元)
|
|
|
sqlFactory.addParameter("amount", item.getBigDecimalValue("amount"));
|
|
|
} else {
|
|
|
@@ -247,9 +247,9 @@ public class OrderItems extends Controller {
|
|
|
}
|
|
|
|
|
|
if (type.equals("促销订单")) {
|
|
|
- Rows promotionRows = dbConnect.runSqlQuery("select * from sa_promotion where siteid='"+siteid+"' and sa_promotionid="+sa_promotionid);
|
|
|
- if(!promotionRows.isEmpty()){
|
|
|
- if(promotionRows.get(0).getString("type").equals("打包促销")){
|
|
|
+ Rows promotionRows = dbConnect.runSqlQuery("select * from sa_promotion where siteid='" + siteid + "' and sa_promotionid=" + sa_promotionid);
|
|
|
+ if (!promotionRows.isEmpty()) {
|
|
|
+ if (promotionRows.get(0).getString("type").equals("打包促销")) {
|
|
|
BigDecimal orderaddqty = promotionRows.get(0).getBigDecimal("orderaddqty");
|
|
|
BigDecimal orderminqty = promotionRows.get(0).getBigDecimal("orderminqty");
|
|
|
if (((sumqty.subtract(orderminqty)).remainder(orderaddqty)).compareTo(BigDecimal.ZERO) != 0) {
|
|
|
@@ -392,7 +392,7 @@ public class OrderItems extends Controller {
|
|
|
public String updateOrderItemsDiscountrate() throws YosException {
|
|
|
Long sa_orderid = content.getLong("sa_orderid");
|
|
|
BigDecimal discountrate = content.getBigDecimal("discountrate");
|
|
|
- JSONArray itemids=content.getJSONArray("itemids");
|
|
|
+ JSONArray itemids = content.getJSONArray("itemids");
|
|
|
Rows orderRows = dbConnect.runSqlQuery("select * from sa_order where sa_orderid=" + sa_orderid + " and siteid='" + siteid + "'");
|
|
|
if (!orderRows.isEmpty()) {
|
|
|
if (!orderRows.get(0).getString("status").equals("新建") && !orderRows.get(0).getString("status").equals("预提交")) {
|
|
|
@@ -402,10 +402,10 @@ public class OrderItems extends Controller {
|
|
|
return getErrReturnObject().setErrMsg("该订单不存在").toString();
|
|
|
}
|
|
|
String sql;
|
|
|
- if(itemids.size()==0){
|
|
|
- sql="select * from sa_orderitems where sa_orderid=" + sa_orderid + " and siteid='" + siteid + "'";
|
|
|
- }else{
|
|
|
- sql="select * from sa_orderitems where sa_orderid=" + sa_orderid + " and siteid='" + siteid + "' and itemid in "+itemids.toJSONString();
|
|
|
+ if (itemids.size() == 0) {
|
|
|
+ sql = "select * from sa_orderitems where sa_orderid=" + sa_orderid + " and siteid='" + siteid + "'";
|
|
|
+ } else {
|
|
|
+ sql = "select * from sa_orderitems where sa_orderid=" + sa_orderid + " and siteid='" + siteid + "' and itemid in " + itemids.toJSONString();
|
|
|
sql = sql.replace("[", "(").replace("]", ")");
|
|
|
}
|
|
|
Rows orderItemsRows = dbConnect.runSqlQuery(sql);
|
|
|
@@ -425,7 +425,7 @@ public class OrderItems extends Controller {
|
|
|
@CACHEING_CLEAN(apiClass = {Order.class, OrderItems.class, restcontroller.sale.order.Order.class, ToolBill.class})
|
|
|
public String updateOrderItemsPrice() throws YosException {
|
|
|
Long sa_orderid = content.getLong("sa_orderid");
|
|
|
- JSONArray itemids=content.getJSONArray("itemids");
|
|
|
+ JSONArray itemids = content.getJSONArray("itemids");
|
|
|
Rows orderRows = dbConnect.runSqlQuery("select * from sa_order where sa_orderid=" + sa_orderid + " and siteid='" + siteid + "'");
|
|
|
if (!orderRows.isEmpty()) {
|
|
|
if (!orderRows.get(0).getString("status").equals("新建") && !orderRows.get(0).getString("status").equals("预提交")) {
|
|
|
@@ -435,11 +435,11 @@ public class OrderItems extends Controller {
|
|
|
return getErrReturnObject().setErrMsg("该订单不存在").toString();
|
|
|
}
|
|
|
String sql;
|
|
|
- if(itemids.size()==0){
|
|
|
- sql="select * from sa_orderitems where sa_orderid=" + sa_orderid + " and siteid='" + siteid + "'";
|
|
|
- }else{
|
|
|
- sql="select * from sa_orderitems where sa_orderid=" + sa_orderid + " and siteid='" + siteid + "' and itemid in "+itemids.toJSONString();
|
|
|
- sql = sql.replace("[", "(").replace("]", ")");
|
|
|
+ if (itemids.size() == 0) {
|
|
|
+ sql = "select * from sa_orderitems where sa_orderid=" + sa_orderid + " and siteid='" + siteid + "'";
|
|
|
+ } else {
|
|
|
+ sql = "select * from sa_orderitems where sa_orderid=" + sa_orderid + " and siteid='" + siteid + "' and itemid in " + itemids.toJSONString();
|
|
|
+ sql = sql.replace("[", "(").replace("]", ")");
|
|
|
}
|
|
|
|
|
|
Rows orderItemsRows = dbConnect.runSqlQuery(sql);
|
|
|
@@ -448,7 +448,7 @@ public class OrderItems extends Controller {
|
|
|
if (!orderItemsRows.isEmpty()) {
|
|
|
for (Row row : orderItemsRows) {
|
|
|
//价格
|
|
|
- ItemPrice itemPrice = ItemPrice.getItemPrice(this,orderRows.get(0).getLong("sys_enterpriseid"), row.getLong("itemid"));
|
|
|
+ ItemPrice itemPrice = ItemPrice.getItemPrice(this, orderRows.get(0).getLong("sys_enterpriseid"), row.getLong("itemid"));
|
|
|
BigDecimal price = itemPrice.getPrice();
|
|
|
BigDecimal amount = row.getBigDecimal("qty").multiply(price);
|
|
|
sqlList.add("update sa_orderitems set price=" + price + ",amount=" + amount + " where sa_orderitemsid=" + row.getLong("sa_orderitemsid"));
|
|
|
@@ -511,10 +511,10 @@ public class OrderItems extends Controller {
|
|
|
Rows sumQtyRows = dbConnect.runSqlQuery(sqlFactory1);
|
|
|
RowsMap sumQtyRowsMap = sumQtyRows.toRowsMap("itemno");
|
|
|
|
|
|
- SQLFactory sqlFactory2 =new SQLFactory(this,"商品未发货数量汇总");
|
|
|
+ SQLFactory sqlFactory2 = new SQLFactory(this, "商品未发货数量汇总");
|
|
|
sqlFactory2.addParameter("siteid", siteid);
|
|
|
Rows sumUnQtyRows = dbConnect.runSqlQuery(sqlFactory2);
|
|
|
- RowsMap sumUnQtyRowsMap= sumUnQtyRows.toRowsMap("itemno");
|
|
|
+ RowsMap sumUnQtyRowsMap = sumUnQtyRows.toRowsMap("itemno");
|
|
|
|
|
|
ERPDocking erpDocking = new ERPDocking();
|
|
|
JSONArray jsonArray = new JSONArray();
|
|
|
@@ -542,9 +542,9 @@ public class OrderItems extends Controller {
|
|
|
} else {
|
|
|
row.put("unsoldqty", BigDecimal.ZERO);
|
|
|
}
|
|
|
- if(sumUnQtyRowsMap.get(row.getString("itemno")).isNotEmpty()){
|
|
|
+ if (sumUnQtyRowsMap.get(row.getString("itemno")).isNotEmpty()) {
|
|
|
row.put("undeliqtysum", sumUnQtyRowsMap.get(row.getString("itemno")).get(0).getBigDecimal("undeliqty"));
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
row.put("undeliqtysum", BigDecimal.ZERO);
|
|
|
}
|
|
|
if (!row.containsKey("invbalqty")) {
|
|
|
@@ -814,9 +814,9 @@ public class OrderItems extends Controller {
|
|
|
// sqlFactory = new SQLFactory(this, "查询可添加商品列表_总部订单", pageSize, pageNumber, pageSorting);
|
|
|
// break;
|
|
|
case "特殊订单":
|
|
|
- if(typemx.equals("电商") || typemx.equals("工程") ){
|
|
|
+ if (typemx.equals("电商") || typemx.equals("工程")) {
|
|
|
sqlFactory = new SQLFactory(this, "查询可添加商品列表_总部订单", pageSize, pageNumber, pageSorting);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
sqlFactory = new SQLFactory(this, "查询可添加商品列表_特殊订单", pageSize, pageNumber, pageSorting);
|
|
|
}
|
|
|
sqlFactory.addParameter("tradefield", tradefield);
|
|
|
@@ -830,8 +830,8 @@ public class OrderItems extends Controller {
|
|
|
boolean saleclassauth = enterpriseRow.getBoolean("saleclassauth");
|
|
|
//需要经营授权
|
|
|
if (saleclassauth) {
|
|
|
- where2.append(" and t1.itemclassid in (SELECT itemclassid from sys_enterprise_saleclass WHERE sys_enterpriseid = " + sys_enterpriseid + " and siteid = '" + siteid + "')");
|
|
|
- }
|
|
|
+ where2.append(" and t1.itemclassid in (SELECT itemclassid from sys_enterprise_saleclass WHERE sys_enterpriseid = " + sys_enterpriseid + " and siteid = '" + siteid + "')");
|
|
|
+ }
|
|
|
sqlFactory.addParameter("sa_brandid", sa_brandid);
|
|
|
sqlFactory.addParameter("tradefield", tradefield);
|
|
|
sqlFactory.addParameter_SQL("where2", where2);
|