|
|
@@ -1,7 +1,6 @@
|
|
|
package restcontroller.webmanage.sale.stockbill;
|
|
|
|
|
|
import beans.brand.Brand;
|
|
|
-import beans.customscheme.CustomScheme;
|
|
|
import beans.data.BatchDeleteErr;
|
|
|
import beans.datacontrllog.DataContrlLog;
|
|
|
import beans.itemprice.ItemPrice;
|
|
|
@@ -54,7 +53,7 @@ public class stockbillitems extends Controller {
|
|
|
where.append(" and t3.checkdate >='").append(whereObject.getString("begindate")).append("' ");
|
|
|
}
|
|
|
if (whereObject.containsKey("enddate") && !"".equals(whereObject.getString("enddate"))) {
|
|
|
- where.append(" and t3.checkdate <='").append(getDate_Str(whereObject.getDate("enddate"),1)).append("' ");
|
|
|
+ where.append(" and t3.checkdate <='").append(getDate_Str(whereObject.getDate("enddate"), 1)).append("' ");
|
|
|
}
|
|
|
if (whereObject.containsKey("type") && !"".equals(whereObject.getString("type"))) {
|
|
|
where.append(" and t3.type ='").append(whereObject.getString("type")).append("' ");
|
|
|
@@ -68,15 +67,15 @@ public class stockbillitems extends Controller {
|
|
|
//
|
|
|
// Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
|
|
|
QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_orderitems", "sa_orderitemsid", "sa_orderid",
|
|
|
- "itemid","unit","undeliqty","remarks","rowno","customproperties","price","defaultprice","custamount");
|
|
|
+ "itemid", "unit", "undeliqty", "remarks", "rowno", "customproperties", "price", "defaultprice", "custamount");
|
|
|
querySQL.setTableAlias("t1");
|
|
|
- querySQL.addJoinTable(JOINTYPE.left, "plm_item", "t2", "t1.siteid = t2.siteid and t1.itemid = t2.itemid","itemno","itemname","model","spec","batchcontrol","icaddqty","icminqty","outplace");
|
|
|
- querySQL.addJoinTable(JOINTYPE.left, "sa_order", "t3", "t1.siteid=t3.siteid and t1.sa_orderid=t3.sa_orderid","sonum","billdate","createdate","submitdate","checkdate","typemx","abstract","delivery","invoicename","invoicetaxno","invoiceaddress");
|
|
|
- querySQL.addQueryFields("orderremarks","t3.remarks");
|
|
|
+ querySQL.addJoinTable(JOINTYPE.left, "plm_item", "t2", "t1.siteid = t2.siteid and t1.itemid = t2.itemid", "itemno", "itemname", "model", "spec", "batchcontrol", "icaddqty", "icminqty", "outplace");
|
|
|
+ querySQL.addJoinTable(JOINTYPE.left, "sa_order", "t3", "t1.siteid=t3.siteid and t1.sa_orderid=t3.sa_orderid", "sonum", "billdate", "createdate", "submitdate", "checkdate", "typemx", "abstract", "delivery", "invoicename", "invoicetaxno", "invoiceaddress");
|
|
|
+ querySQL.addQueryFields("orderremarks", "t3.remarks");
|
|
|
querySQL.setSiteid(siteid);
|
|
|
querySQL.setWhere("t3.STATUS = '审核' and ifnull(t1.undeliqty, 0) !=0 and ifnull(t1.isfreeze, 0) =0 AND ifnull( t1.isclose, 0 )= 0");
|
|
|
- querySQL.setWhere("t3.sys_enterpriseid",content.getLongValue("sys_enterpriseid"));
|
|
|
- querySQL.setWhere("if(ifnull(t2.batchcontrol,0)!=0,1=1,not EXISTS(select 1 from st_stockbill_items where st_stockbillid='"+content.getLongValue("st_stockbillid")+"' and sa_orderitemsid=t1.sa_orderitemsid))");
|
|
|
+ querySQL.setWhere("t3.sys_enterpriseid", content.getLongValue("sys_enterpriseid"));
|
|
|
+ querySQL.setWhere("if(ifnull(t2.batchcontrol,0)!=0,1=1,not EXISTS(select 1 from st_stockbill_items where st_stockbillid='" + content.getLongValue("st_stockbillid") + "' and sa_orderitemsid=t1.sa_orderitemsid))");
|
|
|
//querySQL.setWhere("t1.sa_orderitemsid not in(select t1.sa_orderitemsid from (select t1.sa_orderitemsid,t1.siteid,SUM(t1.qty) qty from sa_dispatch_items t1 inner join sa_dispatch t2 on t1.sa_dispatchid=t2.sa_dispatchid and t1.siteid=t2.siteid where t2.status in('新建','提交') group by t1.sa_orderitemsid,t1.siteid) t1 inner join sa_orderitems t3 on t1.sa_orderitemsid=t3.sa_orderitemsid and t1.siteid=t3.siteid where t3.undeliqty=t1.qty)");
|
|
|
querySQL.setWhere(where.toString());
|
|
|
querySQL.setPage(pageSize, pageNumber);
|
|
|
@@ -89,7 +88,7 @@ public class stockbillitems extends Controller {
|
|
|
public String queryItemList() throws YosException {
|
|
|
long st_stockbillid = content.getLong("st_stockbillid");
|
|
|
Rows stockbillrows = dbConnect.runSqlQuery("select sys_enterpriseid from st_stockbill where st_stockbillid=" + st_stockbillid);
|
|
|
- if(stockbillrows.isEmpty()){
|
|
|
+ if (stockbillrows.isEmpty()) {
|
|
|
return getErrReturnObject().setErrMsg("该出入库单不存在").toString();
|
|
|
}
|
|
|
/*
|
|
|
@@ -108,13 +107,13 @@ public class stockbillitems extends Controller {
|
|
|
|
|
|
}
|
|
|
QuerySQL querySQL = SQLFactory.createQuerySQL(this, "plm_item",
|
|
|
- "itemid","itemno","itemname","model","spec","batchcontrol","outplace","icaddqty","icminqty");
|
|
|
+ "itemid", "itemno", "itemname", "model", "spec", "batchcontrol", "outplace", "icaddqty", "icminqty");
|
|
|
querySQL.setTableAlias("t1");
|
|
|
- querySQL.addJoinTable(JOINTYPE.left, "plm_unit", "t2", "t1.siteid = t2.siteid and t1.unitid = t2.unitid","unitname");
|
|
|
+ querySQL.addJoinTable(JOINTYPE.left, "plm_unit", "t2", "t1.siteid = t2.siteid and t1.unitid = t2.unitid", "unitname");
|
|
|
querySQL.setSiteid(siteid);
|
|
|
- querySQL.addQueryFields("qty","t1.icminqty");
|
|
|
+ querySQL.addQueryFields("qty", "t1.icminqty");
|
|
|
querySQL.setWhere("t1.STATUS = '审核' and t1.isused=1");
|
|
|
- querySQL.setWhere("t1.itemid not in (select itemid from st_stockbill_items where st_stockbillid='"+st_stockbillid+"')");
|
|
|
+ querySQL.setWhere("t1.itemid not in (select itemid from st_stockbill_items where st_stockbillid='" + st_stockbillid + "')");
|
|
|
//querySQL.setWhere("t1.sa_orderitemsid not in(select t1.sa_orderitemsid from (select t1.sa_orderitemsid,t1.siteid,SUM(t1.qty) qty from sa_dispatch_items t1 inner join sa_dispatch t2 on t1.sa_dispatchid=t2.sa_dispatchid and t1.siteid=t2.siteid where t2.status in('新建','提交') group by t1.sa_orderitemsid,t1.siteid) t1 inner join sa_orderitems t3 on t1.sa_orderitemsid=t3.sa_orderitemsid and t1.siteid=t3.siteid where t3.undeliqty=t1.qty)");
|
|
|
querySQL.setWhere(where.toString());
|
|
|
querySQL.setPage(pageSize, pageNumber);
|
|
|
@@ -157,10 +156,10 @@ public class stockbillitems extends Controller {
|
|
|
if (!rowscount.get(0).getString("status").equals("新建")) {
|
|
|
return getErrReturnObject().setErrMsg("非新建状态的出库单无法新增修改").toString();
|
|
|
}
|
|
|
- if(rowscount.get(0).getString("sourceobject").equals("tpartreimbursement")){
|
|
|
+ if (rowscount.get(0).getString("sourceobject").equals("tpartreimbursement")) {
|
|
|
return getErrReturnObject().setErrMsg("由核销生成的出入库单无法新增修改").toString();
|
|
|
}
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
return getErrReturnObject().setErrMsg("出入库单不存在").toString();
|
|
|
}
|
|
|
int i = 0;
|
|
|
@@ -177,14 +176,17 @@ public class stockbillitems extends Controller {
|
|
|
List<Long> list = new ArrayList<>();
|
|
|
|
|
|
for (Object object : iteminfos) {
|
|
|
- list.add(((JSONObject)object).getLong("itemid"));
|
|
|
+ list.add(((JSONObject) object).getLong("itemid"));
|
|
|
}
|
|
|
|
|
|
- RowsMap itemRowsMap = SQLFactory.createQuerySQL(this, "plm_item", "*").setTableAlias("t1").addJoinTable(JOINTYPE.left, "st_stock", "t2", "t1.siteid = t2.siteid and t1.stockno = t2.stockno","stockid").setWhere("itemid", list).query().toRowsMap("itemid");
|
|
|
+ RowsMap itemRowsMap = SQLFactory.createQuerySQL(this, "plm_item", "*").setTableAlias("t1").addJoinTable(JOINTYPE.left, "st_stock", "t2", "t1.siteid = t2.siteid and t1.stockno = t2.stockno", "stockid").setWhere("itemid", list).query().toRowsMap("itemid");
|
|
|
RowsMap stockRowsMap = SQLFactory.createQuerySQL(this, "st_stock", "stockid", "stockno").query().toRowsMap("stockno");
|
|
|
|
|
|
for (Object obj : iteminfos) {
|
|
|
JSONObject iteminfo = (JSONObject) obj;
|
|
|
+ if (!iteminfo.containsKey("custamount")) {
|
|
|
+ iteminfo.put("custamount", 0);
|
|
|
+ }
|
|
|
if (iteminfo.getLong("st_stockbill_itemsid") <= 0 || dbConnect
|
|
|
.runSqlQuery("select st_stockbill_itemsid from st_stockbill_items where st_stockbill_itemsid="
|
|
|
+ iteminfo.getLong("st_stockbill_itemsid"))
|
|
|
@@ -195,64 +197,64 @@ public class stockbillitems extends Controller {
|
|
|
insertSQL.setValue("rowno", maxid + i + 1);
|
|
|
insertSQL.setValue("st_stockbillid", st_stockbillid);
|
|
|
insertSQL.setValue("sa_orderitemsid", iteminfo.getLong("sa_orderitemsid"));
|
|
|
- if(rowscount.get(0).getString("type").equals("其他入库")){
|
|
|
- if(rowscount.get(0).getLong("stockid")!=0){
|
|
|
+ if (rowscount.get(0).getString("type").equals("其他入库")) {
|
|
|
+ if (rowscount.get(0).getLong("stockid") != 0) {
|
|
|
insertSQL.setValue("stockid", rowscount.get(0).getLong("stockid"));
|
|
|
- }else{
|
|
|
- insertSQL.setValue("stockid",itemRowsMap.containsKey(iteminfo.getStringValue("itemid"))?itemRowsMap.get(iteminfo.getStringValue("itemid")).get(0).getLong("stockid"):iteminfo.getLongValue("stockid"));
|
|
|
+ } else {
|
|
|
+ insertSQL.setValue("stockid", itemRowsMap.containsKey(iteminfo.getStringValue("itemid")) ? itemRowsMap.get(iteminfo.getStringValue("itemid")).get(0).getLong("stockid") : iteminfo.getLongValue("stockid"));
|
|
|
}
|
|
|
- }else if(rowscount.get(0).getString("type").equals("销售出库")){
|
|
|
- if(itemRowsMap.containsKey(iteminfo.getStringValue("itemid"))){
|
|
|
- if(itemRowsMap.get(iteminfo.getStringValue("itemid")).get(0).getBoolean("ismodule")){
|
|
|
+ } else if (rowscount.get(0).getString("type").equals("销售出库")) {
|
|
|
+ if (itemRowsMap.containsKey(iteminfo.getStringValue("itemid"))) {
|
|
|
+ if (itemRowsMap.get(iteminfo.getStringValue("itemid")).get(0).getBoolean("ismodule")) {
|
|
|
insertSQL.setValue("stockid", stockRowsMap.get("105").get(0).getLong("stockid"));
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
insertSQL.setValue("stockid", stockRowsMap.get("101").get(0).getLong("stockid"));
|
|
|
}
|
|
|
}
|
|
|
- }else if(rowscount.get(0).getString("type").equals("其他出库")){
|
|
|
- if(rowscount.get(0).getLong("stockid")!=0){
|
|
|
+ } else if (rowscount.get(0).getString("type").equals("其他出库")) {
|
|
|
+ if (rowscount.get(0).getLong("stockid") != 0) {
|
|
|
insertSQL.setValue("stockid", rowscount.get(0).getLong("stockid"));
|
|
|
- }else{
|
|
|
- insertSQL.setValue("stockid",itemRowsMap.containsKey(iteminfo.getStringValue("itemid"))?itemRowsMap.get(iteminfo.getStringValue("itemid")).get(0).getLong("stockid"):iteminfo.getLongValue("stockid"));
|
|
|
+ } else {
|
|
|
+ insertSQL.setValue("stockid", itemRowsMap.containsKey(iteminfo.getStringValue("itemid")) ? itemRowsMap.get(iteminfo.getStringValue("itemid")).get(0).getLong("stockid") : iteminfo.getLongValue("stockid"));
|
|
|
}
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
insertSQL.setValue("stockid", iteminfo.getLong("stockid"));
|
|
|
}
|
|
|
|
|
|
insertSQL.setValue("itemid", iteminfo.getStringValue("itemid"));
|
|
|
insertSQL.setValue("sa_orderid", iteminfo.getLongValue("sa_orderid"));
|
|
|
insertSQL.setValue("qty", iteminfo.getStringValue("qty"));
|
|
|
- insertSQL.setValue("discountrate",1);
|
|
|
+ insertSQL.setValue("discountrate", 1);
|
|
|
insertSQL.setValue("sa_dispatch_itemsid", 0);
|
|
|
insertSQL.setValue("defaultprice", iteminfo.getBigDecimal("price").subtract(iteminfo.getBigDecimal("custamount")));
|
|
|
insertSQL.setValue("remarks", iteminfo.getStringValue("remarks"));
|
|
|
- insertSQL.setValue("itemno", itemRowsMap.containsKey(iteminfo.getStringValue("itemid"))?itemRowsMap.get(iteminfo.getStringValue("itemid")).get(0).getString("itemno"):iteminfo.getString("itemno"));
|
|
|
- insertSQL.setValue("itemname", itemRowsMap.containsKey(iteminfo.getStringValue("itemid"))?itemRowsMap.get(iteminfo.getStringValue("itemid")).get(0).getString("itemname"):iteminfo.getString("itemname"));
|
|
|
- insertSQL.setValue("model", itemRowsMap.containsKey(iteminfo.getStringValue("itemid"))?itemRowsMap.get(iteminfo.getStringValue("itemid")).get(0).getString("model"):iteminfo.getString("model"));
|
|
|
- insertSQL.setValue("price",iteminfo.getBigDecimal("price").subtract(iteminfo.getBigDecimal("custamount")));
|
|
|
+ insertSQL.setValue("itemno", itemRowsMap.containsKey(iteminfo.getStringValue("itemid")) ? itemRowsMap.get(iteminfo.getStringValue("itemid")).get(0).getString("itemno") : iteminfo.getString("itemno"));
|
|
|
+ insertSQL.setValue("itemname", itemRowsMap.containsKey(iteminfo.getStringValue("itemid")) ? itemRowsMap.get(iteminfo.getStringValue("itemid")).get(0).getString("itemname") : iteminfo.getString("itemname"));
|
|
|
+ insertSQL.setValue("model", itemRowsMap.containsKey(iteminfo.getStringValue("itemid")) ? itemRowsMap.get(iteminfo.getStringValue("itemid")).get(0).getString("model") : iteminfo.getString("model"));
|
|
|
+ insertSQL.setValue("price", iteminfo.getBigDecimal("price").subtract(iteminfo.getBigDecimal("custamount")));
|
|
|
insertSQL.setValue("amount", iteminfo.getBigDecimal("qty").multiply((iteminfo.getBigDecimal("price").subtract(iteminfo.getBigDecimal("custamount")))));
|
|
|
insertSQL.setValue("custamount", iteminfo.getBigDecimal("custamount"));
|
|
|
- insertSQL.setValue("untaxedprice", iteminfo.getBigDecimal("price").divide(new BigDecimal(1.13),2, BigDecimal.ROUND_HALF_UP));
|
|
|
- insertSQL.setValue("untaxedamount", iteminfo.getBigDecimal("qty").multiply(iteminfo.getBigDecimal("price").divide(new BigDecimal(1.13),2, BigDecimal.ROUND_HALF_UP)));
|
|
|
- insertSQL.setValue("skucontrol", itemRowsMap.containsKey(iteminfo.getStringValue("itemid"))?itemRowsMap.get(iteminfo.getStringValue("itemid")).get(0).getBoolean("skucontrol"):iteminfo.getBoolean("skucontrol"));
|
|
|
+ insertSQL.setValue("untaxedprice", iteminfo.getBigDecimal("price").divide(new BigDecimal(1.13), 2, BigDecimal.ROUND_HALF_UP));
|
|
|
+ insertSQL.setValue("untaxedamount", iteminfo.getBigDecimal("qty").multiply(iteminfo.getBigDecimal("price").divide(new BigDecimal(1.13), 2, BigDecimal.ROUND_HALF_UP)));
|
|
|
+ insertSQL.setValue("skucontrol", itemRowsMap.containsKey(iteminfo.getStringValue("itemid")) ? itemRowsMap.get(iteminfo.getStringValue("itemid")).get(0).getBoolean("skucontrol") : iteminfo.getBoolean("skucontrol"));
|
|
|
i++;
|
|
|
- if(StringUtils.isBlank(rowscount.get(0).getString("name"))
|
|
|
+ if (StringUtils.isBlank(rowscount.get(0).getString("name"))
|
|
|
|| StringUtils.isBlank(rowscount.get(0).getString("phonenumber"))
|
|
|
- || StringUtils.isBlank(rowscount.get(0).getString("address"))){
|
|
|
- Rows orderRows =dbConnect.runSqlQuery("select * from sa_order where sa_orderid="+iteminfo.getLongValue("sa_orderid"));
|
|
|
- if(orderRows.isNotEmpty()){
|
|
|
- sqlList.add("update st_stockbill set name='"+orderRows.get(0).getString("contact")+"',phonenumber='"+orderRows.get(0).getString("phonenumber")+"',address='"+orderRows.get(0).getString("address")+"' where st_stockbillid="+st_stockbillid);
|
|
|
+ || StringUtils.isBlank(rowscount.get(0).getString("address"))) {
|
|
|
+ Rows orderRows = dbConnect.runSqlQuery("select * from sa_order where sa_orderid=" + iteminfo.getLongValue("sa_orderid"));
|
|
|
+ if (orderRows.isNotEmpty()) {
|
|
|
+ sqlList.add("update st_stockbill set name='" + orderRows.get(0).getString("contact") + "',phonenumber='" + orderRows.get(0).getString("phonenumber") + "',address='" + orderRows.get(0).getString("address") + "' where st_stockbillid=" + st_stockbillid);
|
|
|
}
|
|
|
- }else{
|
|
|
- String depname="";
|
|
|
+ } else {
|
|
|
+ String depname = "";
|
|
|
Rows departmentrows = dbConnect.runSqlQuery("select depname from sys_department where departmentid=" + rowscount.get(0).getLong("departmentid"));
|
|
|
- if(departmentrows.isNotEmpty()){
|
|
|
- depname=departmentrows.get(0).getString("depname");
|
|
|
+ if (departmentrows.isNotEmpty()) {
|
|
|
+ depname = departmentrows.get(0).getString("depname");
|
|
|
}
|
|
|
- if(depname.equals("售后部")){
|
|
|
- Rows orderRows =dbConnect.runSqlQuery("select * from sa_order where sa_orderid="+iteminfo.getLongValue("sa_orderid"));
|
|
|
- if(orderRows.isNotEmpty()){
|
|
|
- sqlList.add("update st_stockbill set name='"+orderRows.get(0).getString("contact")+"',phonenumber='"+orderRows.get(0).getString("phonenumber")+"',address='"+orderRows.get(0).getString("address")+"' where st_stockbillid="+st_stockbillid);
|
|
|
+ if (depname.equals("售后部")) {
|
|
|
+ Rows orderRows = dbConnect.runSqlQuery("select * from sa_order where sa_orderid=" + iteminfo.getLongValue("sa_orderid"));
|
|
|
+ if (orderRows.isNotEmpty()) {
|
|
|
+ sqlList.add("update st_stockbill set name='" + orderRows.get(0).getString("contact") + "',phonenumber='" + orderRows.get(0).getString("phonenumber") + "',address='" + orderRows.get(0).getString("address") + "' where st_stockbillid=" + st_stockbillid);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -279,16 +281,16 @@ public class stockbillitems extends Controller {
|
|
|
updateSQL.setValue("model", iteminfo.getString("model"));
|
|
|
updateSQL.setValue("price", iteminfo.getString("price"));
|
|
|
updateSQL.setValue("amount", iteminfo.getBigDecimal("qty").multiply(iteminfo.getBigDecimal("price")));
|
|
|
- updateSQL.setValue("untaxedprice", iteminfo.getBigDecimal("price").divide(new BigDecimal(1.13),2, BigDecimal.ROUND_HALF_UP));
|
|
|
- updateSQL.setValue("untaxedamount", iteminfo.getBigDecimal("qty").multiply(iteminfo.getBigDecimal("price").divide(new BigDecimal(1.13),2, BigDecimal.ROUND_HALF_UP)));
|
|
|
+ updateSQL.setValue("untaxedprice", iteminfo.getBigDecimal("price").divide(new BigDecimal(1.13), 2, BigDecimal.ROUND_HALF_UP));
|
|
|
+ updateSQL.setValue("untaxedamount", iteminfo.getBigDecimal("qty").multiply(iteminfo.getBigDecimal("price").divide(new BigDecimal(1.13), 2, BigDecimal.ROUND_HALF_UP)));
|
|
|
updateSQL.setValue("batchno", iteminfo.getString("batchno"));
|
|
|
updateSQL.setValue("stockid", iteminfo.getString("stockid"));
|
|
|
- updateSQL.setValue("skucontrol",itemRowsMap.containsKey(iteminfo.getStringValue("itemid"))?itemRowsMap.get(iteminfo.getStringValue("itemid")).get(0).getBoolean("skucontrol"):iteminfo.getBoolean("skucontrol"));
|
|
|
- if(detailRowsMap.containsKey(iteminfo.getString("st_stockbill_itemsid"))){
|
|
|
- if(iteminfo.getBigDecimal("discountrate").compareTo(detailRowsMap.get(iteminfo.getString("st_stockbill_itemsid")).get(0).getBigDecimal("discountrate"))!=0
|
|
|
- || iteminfo.getBigDecimal("defaultprice").compareTo(detailRowsMap.get(iteminfo.getString("st_stockbill_itemsid")).get(0).getBigDecimal("defaultprice"))!=0
|
|
|
- || iteminfo.getBigDecimal("price").compareTo(detailRowsMap.get(iteminfo.getString("st_stockbill_itemsid")).get(0).getBigDecimal("price"))!=0){
|
|
|
- sqlList.add(DataContrlLog.createLog(this, "st_stockbill", st_stockbillid, "明细金额变更", "行号【"+detailRowsMap.get(iteminfo.getString("st_stockbill_itemsid")).get(0).getString("rowno")+"】原价:"+iteminfo.getBigDecimal("defaultprice")+",折后价:"+iteminfo.getBigDecimal("price")+",折扣率:"+iteminfo.getBigDecimal("discountrate")).getSQL());
|
|
|
+ updateSQL.setValue("skucontrol", itemRowsMap.containsKey(iteminfo.getStringValue("itemid")) ? itemRowsMap.get(iteminfo.getStringValue("itemid")).get(0).getBoolean("skucontrol") : iteminfo.getBoolean("skucontrol"));
|
|
|
+ if (detailRowsMap.containsKey(iteminfo.getString("st_stockbill_itemsid"))) {
|
|
|
+ if (iteminfo.getBigDecimal("discountrate").compareTo(detailRowsMap.get(iteminfo.getString("st_stockbill_itemsid")).get(0).getBigDecimal("discountrate")) != 0
|
|
|
+ || iteminfo.getBigDecimal("defaultprice").compareTo(detailRowsMap.get(iteminfo.getString("st_stockbill_itemsid")).get(0).getBigDecimal("defaultprice")) != 0
|
|
|
+ || iteminfo.getBigDecimal("price").compareTo(detailRowsMap.get(iteminfo.getString("st_stockbill_itemsid")).get(0).getBigDecimal("price")) != 0) {
|
|
|
+ sqlList.add(DataContrlLog.createLog(this, "st_stockbill", st_stockbillid, "明细金额变更", "行号【" + detailRowsMap.get(iteminfo.getString("st_stockbill_itemsid")).get(0).getString("rowno") + "】原价:" + iteminfo.getBigDecimal("defaultprice") + ",折后价:" + iteminfo.getBigDecimal("price") + ",折扣率:" + iteminfo.getBigDecimal("discountrate")).getSQL());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -308,27 +310,27 @@ public class stockbillitems extends Controller {
|
|
|
|
|
|
|
|
|
Rows rowsdetail = dbConnect.runSqlQuery("select amount,qty from st_stockbill_items where st_stockbillid=" + st_stockbillid);
|
|
|
- Rows stockbillrows= dbConnect.runSqlQuery("select t1.sys_enterpriseid,t1.paydiscountamount,t2.depname from st_stockbill t1 left join sys_department t2 on t1.departmentid=t2.departmentid where t1.st_stockbillid=" + st_stockbillid);
|
|
|
+ Rows stockbillrows = dbConnect.runSqlQuery("select t1.sys_enterpriseid,t1.paydiscountamount,t2.depname from st_stockbill t1 left join sys_department t2 on t1.departmentid=t2.departmentid where t1.st_stockbillid=" + st_stockbillid);
|
|
|
Rows accountbalancerows = dbConnect.runSqlQuery("select * from sa_accountbalance t1 inner join sa_accountclass t2 on t1.sa_accountclassid=t2.sa_accountclassid and t1.siteid=t2.siteid where t2.accountname='现金账户' and t1.sys_enterpriseid=" + stockbillrows.get(0).getLong("sys_enterpriseid"));
|
|
|
- String depname= stockbillrows.get(0).getString("depname");
|
|
|
- BigDecimal payamount=rowsdetail.sum("amount");
|
|
|
- if(depname.equals("售后部")){
|
|
|
- if(accountbalancerows.isNotEmpty()){
|
|
|
- if(accountbalancerows.get(0).getBigDecimal("discountamount").compareTo(BigDecimal.ZERO)>0){
|
|
|
- if(accountbalancerows.get(0).getBigDecimal("discountamount").compareTo(payamount)>0){
|
|
|
- dbConnect.runSqlUpdate("update st_stockbill set payamount=0,paydiscountamount="+payamount+" where st_stockbillid="+st_stockbillid);
|
|
|
- }else{
|
|
|
- dbConnect.runSqlUpdate("update st_stockbill set payamount="+payamount.subtract(accountbalancerows.get(0).getBigDecimal("discountamount"))+",paydiscountamount="+accountbalancerows.get(0).getBigDecimal("discountamount")+" where st_stockbillid="+st_stockbillid);
|
|
|
+ String depname = stockbillrows.get(0).getString("depname");
|
|
|
+ BigDecimal payamount = rowsdetail.sum("amount");
|
|
|
+ if (depname.equals("售后部")) {
|
|
|
+ if (accountbalancerows.isNotEmpty()) {
|
|
|
+ if (accountbalancerows.get(0).getBigDecimal("discountamount").compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+ if (accountbalancerows.get(0).getBigDecimal("discountamount").compareTo(payamount) > 0) {
|
|
|
+ dbConnect.runSqlUpdate("update st_stockbill set payamount=0,paydiscountamount=" + payamount + " where st_stockbillid=" + st_stockbillid);
|
|
|
+ } else {
|
|
|
+ dbConnect.runSqlUpdate("update st_stockbill set payamount=" + payamount.subtract(accountbalancerows.get(0).getBigDecimal("discountamount")) + ",paydiscountamount=" + accountbalancerows.get(0).getBigDecimal("discountamount") + " where st_stockbillid=" + st_stockbillid);
|
|
|
}
|
|
|
- }else{
|
|
|
- dbConnect.runSqlUpdate("update st_stockbill set payamount="+payamount+",paydiscountamount=0 where st_stockbillid="+st_stockbillid);
|
|
|
+ } else {
|
|
|
+ dbConnect.runSqlUpdate("update st_stockbill set payamount=" + payamount + ",paydiscountamount=0 where st_stockbillid=" + st_stockbillid);
|
|
|
}
|
|
|
|
|
|
- }else{
|
|
|
- dbConnect.runSqlUpdate("update st_stockbill set payamount="+payamount+",paydiscountamount=0 where st_stockbillid="+st_stockbillid);
|
|
|
+ } else {
|
|
|
+ dbConnect.runSqlUpdate("update st_stockbill set payamount=" + payamount + ",paydiscountamount=0 where st_stockbillid=" + st_stockbillid);
|
|
|
}
|
|
|
- }else{
|
|
|
- dbConnect.runSqlUpdate("update st_stockbill set payamount="+payamount+",paydiscountamount=0 where st_stockbillid="+st_stockbillid);
|
|
|
+ } else {
|
|
|
+ dbConnect.runSqlUpdate("update st_stockbill set payamount=" + payamount + ",paydiscountamount=0 where st_stockbillid=" + st_stockbillid);
|
|
|
}
|
|
|
return querStcokbillItemsList();
|
|
|
}
|
|
|
@@ -370,19 +372,19 @@ public class stockbillitems extends Controller {
|
|
|
sqlFactory.addParameter("st_stockbillid", st_stockbillid);
|
|
|
sqlFactory.addParameter("siteid", siteid);
|
|
|
// Rows rows = dbConnect.runSqlQuery(sqlFactory);
|
|
|
- QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sys_site_parameter", "sys_site_parameterid");
|
|
|
+ QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sys_site_parameter", "sys_site_parameterid");
|
|
|
querySQL.setTableAlias("t0");
|
|
|
- querySQL.addJoinTable(JOINTYPE.right, sqlFactory, "t1", "t0.siteid='111'","*");
|
|
|
+ querySQL.addJoinTable(JOINTYPE.right, sqlFactory, "t1", "t0.siteid='111'", "*");
|
|
|
querySQL.setPage(pageSize, pageNumber);
|
|
|
Rows rows = querySQL.query();
|
|
|
|
|
|
- Rows stockbillskuRows = dbConnect.runSqlQuery("select t1.sku,t1.st_stockbill_itemsid from st_stockbill_items_sku t1 left join sa_itemsku t2 on t1.sku=t2.sku where t1.st_stockbillid!=t1.st_stockbill_itemsid and t1.st_stockbillid="+st_stockbillid);
|
|
|
+ Rows stockbillskuRows = dbConnect.runSqlQuery("select t1.sku,t1.st_stockbill_itemsid from st_stockbill_items_sku t1 left join sa_itemsku t2 on t1.sku=t2.sku where t1.st_stockbillid!=t1.st_stockbill_itemsid and t1.st_stockbillid=" + st_stockbillid);
|
|
|
RowsMap stockbillskuRowsMap = stockbillskuRows.toRowsMap("st_stockbill_itemsid");
|
|
|
- for(Row row :rows){
|
|
|
- if(stockbillskuRowsMap.containsKey(row.getString("st_stockbill_itemsid"))){
|
|
|
- row.put("scanqty",stockbillskuRowsMap.get(row.getString("st_stockbill_itemsid")).size());
|
|
|
- }else{
|
|
|
- row.put("scanqty",0);
|
|
|
+ for (Row row : rows) {
|
|
|
+ if (stockbillskuRowsMap.containsKey(row.getString("st_stockbill_itemsid"))) {
|
|
|
+ row.put("scanqty", stockbillskuRowsMap.get(row.getString("st_stockbill_itemsid")).size());
|
|
|
+ } else {
|
|
|
+ row.put("scanqty", 0);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -421,31 +423,32 @@ public class stockbillitems extends Controller {
|
|
|
updateRowNo(st_stockbillid);
|
|
|
|
|
|
Rows rowsdetail = dbConnect.runSqlQuery("select amount,qty from st_stockbill_items where st_stockbillid=" + st_stockbillid);
|
|
|
- Rows stockbillrows= dbConnect.runSqlQuery("select t1.sys_enterpriseid,t1.paydiscountamount,t2.depname from st_stockbill t1 left join sys_department t2 on t1.departmentid=t2.departmentid where t1.st_stockbillid=" + st_stockbillid);
|
|
|
+ Rows stockbillrows = dbConnect.runSqlQuery("select t1.sys_enterpriseid,t1.paydiscountamount,t2.depname from st_stockbill t1 left join sys_department t2 on t1.departmentid=t2.departmentid where t1.st_stockbillid=" + st_stockbillid);
|
|
|
Rows accountbalancerows = dbConnect.runSqlQuery("select * from sa_accountbalance t1 inner join sa_accountclass t2 on t1.sa_accountclassid=t2.sa_accountclassid and t1.siteid=t2.siteid where t2.accountname='现金账户' and t1.sys_enterpriseid=" + stockbillrows.get(0).getLong("sys_enterpriseid"));
|
|
|
- String depname= stockbillrows.get(0).getString("depname");
|
|
|
- BigDecimal payamount=rowsdetail.sum("amount");
|
|
|
- if(depname.equals("售后部")){
|
|
|
- if(accountbalancerows.isNotEmpty()){
|
|
|
- if(accountbalancerows.get(0).getBigDecimal("discountamount").compareTo(BigDecimal.ZERO)>0){
|
|
|
- if(accountbalancerows.get(0).getBigDecimal("discountamount").compareTo(payamount)>0){
|
|
|
- dbConnect.runSqlUpdate("update st_stockbill set payamount=0,paydiscountamount="+payamount+" where st_stockbillid="+st_stockbillid);
|
|
|
- }else{
|
|
|
- dbConnect.runSqlUpdate("update st_stockbill set payamount="+payamount.subtract(accountbalancerows.get(0).getBigDecimal("discountamount"))+",paydiscountamount="+accountbalancerows.get(0).getBigDecimal("discountamount")+" where st_stockbillid="+st_stockbillid);
|
|
|
+ String depname = stockbillrows.get(0).getString("depname");
|
|
|
+ BigDecimal payamount = rowsdetail.sum("amount");
|
|
|
+ if (depname.equals("售后部")) {
|
|
|
+ if (accountbalancerows.isNotEmpty()) {
|
|
|
+ if (accountbalancerows.get(0).getBigDecimal("discountamount").compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+ if (accountbalancerows.get(0).getBigDecimal("discountamount").compareTo(payamount) > 0) {
|
|
|
+ dbConnect.runSqlUpdate("update st_stockbill set payamount=0,paydiscountamount=" + payamount + " where st_stockbillid=" + st_stockbillid);
|
|
|
+ } else {
|
|
|
+ dbConnect.runSqlUpdate("update st_stockbill set payamount=" + payamount.subtract(accountbalancerows.get(0).getBigDecimal("discountamount")) + ",paydiscountamount=" + accountbalancerows.get(0).getBigDecimal("discountamount") + " where st_stockbillid=" + st_stockbillid);
|
|
|
}
|
|
|
- }else{
|
|
|
- dbConnect.runSqlUpdate("update st_stockbill set payamount="+payamount+",paydiscountamount=0 where st_stockbillid="+st_stockbillid);
|
|
|
+ } else {
|
|
|
+ dbConnect.runSqlUpdate("update st_stockbill set payamount=" + payamount + ",paydiscountamount=0 where st_stockbillid=" + st_stockbillid);
|
|
|
}
|
|
|
|
|
|
- }else{
|
|
|
- dbConnect.runSqlUpdate("update st_stockbill set payamount="+payamount+",paydiscountamount=0 where st_stockbillid="+st_stockbillid);
|
|
|
+ } else {
|
|
|
+ dbConnect.runSqlUpdate("update st_stockbill set payamount=" + payamount + ",paydiscountamount=0 where st_stockbillid=" + st_stockbillid);
|
|
|
}
|
|
|
- }else{
|
|
|
- dbConnect.runSqlUpdate("update st_stockbill set payamount="+payamount+",paydiscountamount=0 where st_stockbillid="+st_stockbillid);
|
|
|
+ } else {
|
|
|
+ dbConnect.runSqlUpdate("update st_stockbill set payamount=" + payamount + ",paydiscountamount=0 where st_stockbillid=" + st_stockbillid);
|
|
|
}
|
|
|
|
|
|
return batchDeleteErr.getReturnObject().toString();
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 重新对发货单行进行排序
|
|
|
*
|