|
@@ -42,16 +42,16 @@ public class XSCK extends BasicBill {
|
|
|
}
|
|
}
|
|
|
BigDecimal discountamount = accountbalancerows.get(0).getBigDecimal("discountamount");
|
|
BigDecimal discountamount = accountbalancerows.get(0).getBigDecimal("discountamount");
|
|
|
if (billRow.getBigDecimal("paydiscountamount").compareTo(discountamount) > 0) {
|
|
if (billRow.getBigDecimal("paydiscountamount").compareTo(discountamount) > 0) {
|
|
|
- if(rb==1){
|
|
|
|
|
|
|
+ if (rb == 1) {
|
|
|
throw new YosException("优惠金额不能大于可用优惠金额");
|
|
throw new YosException("优惠金额不能大于可用优惠金额");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- if(billRow.getString("sourceobject").equals("tpartreimbursement")){
|
|
|
|
|
- QuerySQL querySQL = SQLFactory.createQuerySQL(controller, "sa_tpartreimbursementdetail", "sa_tpartreimbursementdetailid","isverified","qty","sa_orderitemsid");
|
|
|
|
|
|
|
+ if (billRow.getString("sourceobject").equals("tpartreimbursement")) {
|
|
|
|
|
+ QuerySQL querySQL = SQLFactory.createQuerySQL(controller, "sa_tpartreimbursementdetail", "sa_tpartreimbursementdetailid", "isverified", "qty", "sa_orderitemsid");
|
|
|
querySQL.setTableAlias("t1");
|
|
querySQL.setTableAlias("t1");
|
|
|
querySQL.addJoinTable(BaseClass.JOINTYPE.inner, "sa_tpartreimbursement", "t3", "t1.sa_tpartreimbursementid = t3.sa_tpartreimbursementid AND t1.siteid = t3.siteid");
|
|
querySQL.addJoinTable(BaseClass.JOINTYPE.inner, "sa_tpartreimbursement", "t3", "t1.sa_tpartreimbursementid = t3.sa_tpartreimbursementid AND t1.siteid = t3.siteid");
|
|
|
querySQL.setSiteid(siteid);
|
|
querySQL.setSiteid(siteid);
|
|
|
- querySQL.setWhere("t1.hongbillno='"+billno+"'");
|
|
|
|
|
|
|
+ querySQL.setWhere("t1.hongbillno='" + billno + "'");
|
|
|
Rows rows = querySQL.query();
|
|
Rows rows = querySQL.query();
|
|
|
for (Row row : rows) {
|
|
for (Row row : rows) {
|
|
|
if (row.getBoolean("isverified")) {
|
|
if (row.getBoolean("isverified")) {
|
|
@@ -70,14 +70,14 @@ public class XSCK extends BasicBill {
|
|
|
if (billRow.getBoolean("isreceiver")) {
|
|
if (billRow.getBoolean("isreceiver")) {
|
|
|
throw new YosException("经销商已经确认收货,不可进行反审核");
|
|
throw new YosException("经销商已经确认收货,不可进行反审核");
|
|
|
}
|
|
}
|
|
|
- if(rb==1){
|
|
|
|
|
- QuerySQL querySQL = SQLFactory.createQuerySQL(controller, "sa_orderitems","verifiedqty");
|
|
|
|
|
|
|
+ if (rb == 1) {
|
|
|
|
|
+ QuerySQL querySQL = SQLFactory.createQuerySQL(controller, "sa_orderitems", "verifiedqty");
|
|
|
querySQL.setTableAlias("t1");
|
|
querySQL.setTableAlias("t1");
|
|
|
querySQL.setSiteid(siteid);
|
|
querySQL.setSiteid(siteid);
|
|
|
- querySQL.setWhere("t1.sa_orderitemsid",itemRows.toArrayList("sa_orderitemsid"));
|
|
|
|
|
|
|
+ querySQL.setWhere("t1.sa_orderitemsid", itemRows.toArrayList("sa_orderitemsid"));
|
|
|
Rows rows = querySQL.query();
|
|
Rows rows = querySQL.query();
|
|
|
for (Row row : rows) {
|
|
for (Row row : rows) {
|
|
|
- if (row.getBigDecimal("verifiedqty").compareTo(BigDecimal.ZERO)>0) {
|
|
|
|
|
|
|
+ if (row.getBigDecimal("verifiedqty").compareTo(BigDecimal.ZERO) > 0) {
|
|
|
throw new YosException("存在对应订单明细已核销,销售出库单无法反审核");
|
|
throw new YosException("存在对应订单明细已核销,销售出库单无法反审核");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -91,18 +91,18 @@ public class XSCK extends BasicBill {
|
|
|
}
|
|
}
|
|
|
//库存校验
|
|
//库存校验
|
|
|
RowsMap invbalsRowsMap = SQLFactory.createQuerySQL(dbConnect, "st_invbal").setWhere("siteid", siteid).setWhere("itemid", itemRows.toArrayList("itemid")).query().toRowsMap("itemid");
|
|
RowsMap invbalsRowsMap = SQLFactory.createQuerySQL(dbConnect, "st_invbal").setWhere("siteid", siteid).setWhere("itemid", itemRows.toArrayList("itemid")).query().toRowsMap("itemid");
|
|
|
- for(Row row : itemRows){
|
|
|
|
|
- if(!row.getBoolean("isnegative") && row.getBoolean("ismodule")){
|
|
|
|
|
|
|
+ for (Row row : itemRows) {
|
|
|
|
|
+ if (!row.getBoolean("isnegative") && row.getBoolean("ismodule")) {
|
|
|
long itemid = row.getLong("itemid");
|
|
long itemid = row.getLong("itemid");
|
|
|
long stockid = row.getLong("stockid");
|
|
long stockid = row.getLong("stockid");
|
|
|
- BigDecimal qty =row.getBigDecimal("qty");
|
|
|
|
|
- if(!isInStock(ischeck)){
|
|
|
|
|
|
|
+ BigDecimal qty = row.getBigDecimal("qty");
|
|
|
|
|
+ if (!isInStock(ischeck)) {
|
|
|
if (!invbalsRowsMap.containsKey(String.valueOf(itemid)) || !invbalsRowsMap.get(String.valueOf(itemid)).toRowsMap("stockid").containsKey(String.valueOf(stockid))) {
|
|
if (!invbalsRowsMap.containsKey(String.valueOf(itemid)) || !invbalsRowsMap.get(String.valueOf(itemid)).toRowsMap("stockid").containsKey(String.valueOf(stockid))) {
|
|
|
- throw new YosException("行【"+row.getString("rowno")+"】不能负库存出库");
|
|
|
|
|
|
|
+ throw new YosException("行【" + row.getString("rowno") + "】不能负库存出库");
|
|
|
} else {
|
|
} else {
|
|
|
BigDecimal invbalqty = invbalsRowsMap.get(String.valueOf(itemid)).toRowsMap("stockid").get(String.valueOf(stockid)).get(0).getBigDecimal("qty");
|
|
BigDecimal invbalqty = invbalsRowsMap.get(String.valueOf(itemid)).toRowsMap("stockid").get(String.valueOf(stockid)).get(0).getBigDecimal("qty");
|
|
|
- if(invbalqty.compareTo(qty)<0){
|
|
|
|
|
- throw new YosException("行【"+row.getString("rowno")+"】不能负库存出库");
|
|
|
|
|
|
|
+ if (invbalqty.compareTo(qty) < 0) {
|
|
|
|
|
+ throw new YosException("行【" + row.getString("rowno") + "】不能负库存出库");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -114,12 +114,12 @@ public class XSCK extends BasicBill {
|
|
|
// if (order_paymentnode.equals("3") && !Accountbalance.judgeBalance(dbConnect, sys_enterpriseid, accountbalancerows.get(0).getLong("sa_accountclassid"), itemRows.toRowsMap("sa_orderitemsidnum").get("0").sum("amount"))) {
|
|
// if (order_paymentnode.equals("3") && !Accountbalance.judgeBalance(dbConnect, sys_enterpriseid, accountbalancerows.get(0).getLong("sa_accountclassid"), itemRows.toRowsMap("sa_orderitemsidnum").get("0").sum("amount"))) {
|
|
|
// //throw new YosException("账户余额不足,还差" + Accountbalance.InsufficientBalance(dbConnect, sys_enterpriseid, accountbalancerows.get(0).getLong("sa_accountclassid"), itemRows.toRowsMap("sa_orderitemsidnum").get("0").sum("amount")) + "元!");
|
|
// //throw new YosException("账户余额不足,还差" + Accountbalance.InsufficientBalance(dbConnect, sys_enterpriseid, accountbalancerows.get(0).getLong("sa_accountclassid"), itemRows.toRowsMap("sa_orderitemsidnum").get("0").sum("amount")) + "元!");
|
|
|
// }
|
|
// }
|
|
|
- if(!billRow.getString("sourceobject").equals("tpartreimbursement")){
|
|
|
|
|
|
|
+ if (!billRow.getString("sourceobject").equals("tpartreimbursement")) {
|
|
|
Rows rowsjudge = dbConnect.runSqlQuery("select * from (select sa_orderitemsid,sum(qty) qty from st_stockbill_items where st_stockbillid ='" + st_stockbillid + "' group by sa_orderitemsid) t1 inner join sa_orderitems t2 on t1.sa_orderitemsid=t2.sa_orderitemsid where t1.qty>t2.undeliqty");
|
|
Rows rowsjudge = dbConnect.runSqlQuery("select * from (select sa_orderitemsid,sum(qty) qty from st_stockbill_items where st_stockbillid ='" + st_stockbillid + "' group by sa_orderitemsid) t1 inner join sa_orderitems t2 on t1.sa_orderitemsid=t2.sa_orderitemsid where t1.qty>t2.undeliqty");
|
|
|
if (rowsjudge.isNotEmpty()) {
|
|
if (rowsjudge.isNotEmpty()) {
|
|
|
- if(ischeck){
|
|
|
|
|
|
|
+ if (ischeck) {
|
|
|
throw new YosException("存在商品已完全出库,无法审核");
|
|
throw new YosException("存在商品已完全出库,无法审核");
|
|
|
- }else{
|
|
|
|
|
|
|
+ } else {
|
|
|
throw new YosException("存在商品已完全出库,无法反审核");
|
|
throw new YosException("存在商品已完全出库,无法反审核");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -138,9 +138,9 @@ public class XSCK extends BasicBill {
|
|
|
String order_paymentnode = Parameter.getString(siteid, "order_paymentnode");
|
|
String order_paymentnode = Parameter.getString(siteid, "order_paymentnode");
|
|
|
if (rb == 1) {
|
|
if (rb == 1) {
|
|
|
if (order_paymentnode.equals("3")) {
|
|
if (order_paymentnode.equals("3")) {
|
|
|
- CashbillEntity entity = getCashbillEntity(billRow.getBigDecimal("payamount"), billRow.getBigDecimal("paydiscountamount"), st_stockbillid, "销售出库单审核", billno, "由销售出库单" + billno + "审核时生成","货款");
|
|
|
|
|
|
|
+ CashbillEntity entity = getCashbillEntity(billRow.getString("billdate"),billRow.getBigDecimal("payamount"), billRow.getBigDecimal("paydiscountamount"), st_stockbillid, "销售出库单审核", billno, "由销售出库单" + billno + "审核时生成", "货款");
|
|
|
JSONObject createCashbillPay = Accountbalance.createCashbillPay(dbConnect, userInfo, sys_enterpriseid, accountbalancerows.get(0).getLong("sa_accountclassid"), entity, true);
|
|
JSONObject createCashbillPay = Accountbalance.createCashbillPay(dbConnect, userInfo, sys_enterpriseid, accountbalancerows.get(0).getLong("sa_accountclassid"), entity, true);
|
|
|
- if(!(billRow.getBigDecimal("payamount").compareTo(BigDecimal.ZERO)==0 && billRow.getBigDecimal("paydiscountamount").compareTo(BigDecimal.ZERO)==0)){
|
|
|
|
|
|
|
+ if (!(billRow.getBigDecimal("payamount").compareTo(BigDecimal.ZERO) == 0 && billRow.getBigDecimal("paydiscountamount").compareTo(BigDecimal.ZERO) == 0)) {
|
|
|
sqlList.addAll(createCashbillPay.getJSONArray("sqlList").toJavaList(String.class));
|
|
sqlList.addAll(createCashbillPay.getJSONArray("sqlList").toJavaList(String.class));
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -158,58 +158,58 @@ public class XSCK extends BasicBill {
|
|
|
sqlList.addAll(updateAccountbalance_freez(isInStock(ischeck)));
|
|
sqlList.addAll(updateAccountbalance_freez(isInStock(ischeck)));
|
|
|
//判断是否关闭订单
|
|
//判断是否关闭订单
|
|
|
int orderautoclosepoint = Parameter.getInteger(siteid, "orderautoclosepoint");
|
|
int orderautoclosepoint = Parameter.getInteger(siteid, "orderautoclosepoint");
|
|
|
- if(orderautoclosepoint==2){
|
|
|
|
|
- ArrayList<Long> sa_orderids = itemRows.toArrayList("sa_orderid",new ArrayList<>());
|
|
|
|
|
|
|
+ if (orderautoclosepoint == 2) {
|
|
|
|
|
+ ArrayList<Long> sa_orderids = itemRows.toArrayList("sa_orderid", new ArrayList<>());
|
|
|
QuerySQL querySQL = SQLFactory.createQuerySQL(controller, "sa_order", "sa_orderid");
|
|
QuerySQL querySQL = SQLFactory.createQuerySQL(controller, "sa_order", "sa_orderid");
|
|
|
querySQL.addJoinTable(BaseClass.JOINTYPE.inner, "sa_orderitems", "t2", "t2.sa_orderid = t1.sa_orderid and t2.siteid = t1.siteid",
|
|
querySQL.addJoinTable(BaseClass.JOINTYPE.inner, "sa_orderitems", "t2", "t2.sa_orderid = t1.sa_orderid and t2.siteid = t1.siteid",
|
|
|
- "undeliqty","sa_orderitemsid");
|
|
|
|
|
|
|
+ "undeliqty", "sa_orderitemsid");
|
|
|
querySQL.setTableAlias("t1");
|
|
querySQL.setTableAlias("t1");
|
|
|
querySQL.setWhere("t1.siteid", siteid);
|
|
querySQL.setWhere("t1.siteid", siteid);
|
|
|
querySQL.setWhere("t1.sa_orderid", sa_orderids);
|
|
querySQL.setWhere("t1.sa_orderid", sa_orderids);
|
|
|
querySQL.setWhere("t1.status='审核' and t2.undeliqty!=0");
|
|
querySQL.setWhere("t1.status='审核' and t2.undeliqty!=0");
|
|
|
Rows rows = querySQL.query();
|
|
Rows rows = querySQL.query();
|
|
|
- RowsMap rowsMap =rows.toRowsMap("sa_orderid");
|
|
|
|
|
- RowsMap itemRowsMap=itemRows.toRowsMap("sa_orderid");
|
|
|
|
|
- for(Long sa_orderid : sa_orderids){
|
|
|
|
|
- Rows stockbillitemrows = itemRowsMap.getOrDefault(String.valueOf(sa_orderid),new Rows());
|
|
|
|
|
- Rows orderrows = rowsMap.getOrDefault(String.valueOf(sa_orderid),new Rows());
|
|
|
|
|
- RowsMap stockbillitemrowsMap =stockbillitemrows.toRowsMap("sa_orderitemsid");
|
|
|
|
|
- int count=0;
|
|
|
|
|
- for(Row row : orderrows){
|
|
|
|
|
- if(stockbillitemrowsMap.containsKey(row.getString("sa_orderitemsid"))){
|
|
|
|
|
- if(stockbillitemrowsMap.getOrDefault(row.getString("sa_orderitemsid"),new Rows()).sum("qty").compareTo(row.getBigDecimal("undeliqty"))==0){
|
|
|
|
|
|
|
+ RowsMap rowsMap = rows.toRowsMap("sa_orderid");
|
|
|
|
|
+ RowsMap itemRowsMap = itemRows.toRowsMap("sa_orderid");
|
|
|
|
|
+ for (Long sa_orderid : sa_orderids) {
|
|
|
|
|
+ Rows stockbillitemrows = itemRowsMap.getOrDefault(String.valueOf(sa_orderid), new Rows());
|
|
|
|
|
+ Rows orderrows = rowsMap.getOrDefault(String.valueOf(sa_orderid), new Rows());
|
|
|
|
|
+ RowsMap stockbillitemrowsMap = stockbillitemrows.toRowsMap("sa_orderitemsid");
|
|
|
|
|
+ int count = 0;
|
|
|
|
|
+ for (Row row : orderrows) {
|
|
|
|
|
+ if (stockbillitemrowsMap.containsKey(row.getString("sa_orderitemsid"))) {
|
|
|
|
|
+ if (stockbillitemrowsMap.getOrDefault(row.getString("sa_orderitemsid"), new Rows()).sum("qty").compareTo(row.getBigDecimal("undeliqty")) == 0) {
|
|
|
count++;
|
|
count++;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- if(orderrows.size()==count){
|
|
|
|
|
- sqlList.add("update sa_order set status='关闭',closeby='"+controller.username+"',closedate=CURRENT_TIME where sa_orderid=" +sa_orderid);
|
|
|
|
|
|
|
+ if (orderrows.size() == count) {
|
|
|
|
|
+ sqlList.add("update sa_order set status='关闭',closeby='" + controller.username + "',closedate=CURRENT_TIME where sa_orderid=" + sa_orderid);
|
|
|
sqlList.add("UPDATE sa_accountbalance t1 " +
|
|
sqlList.add("UPDATE sa_accountbalance t1 " +
|
|
|
"INNER JOIN sa_accountbalance_freez t2 ON t1.sa_accountbalanceid = t2.sa_accountbalanceid " +
|
|
"INNER JOIN sa_accountbalance_freez t2 ON t1.sa_accountbalanceid = t2.sa_accountbalanceid " +
|
|
|
"SET t1.freezamount = case when ifnull(t1.freezamount,0)>t2.amount then t1.freezamount-t2.amount else 0 end " +
|
|
"SET t1.freezamount = case when ifnull(t1.freezamount,0)>t2.amount then t1.freezamount-t2.amount else 0 end " +
|
|
|
- "WHERE t1.sa_accountbalanceid="+accountbalancerows.get(0).getLong("sa_accountbalanceid")+" and t2.sourcetable='sa_order' and t2.sourceid="+sa_orderid);
|
|
|
|
|
- sqlList.add("delete from sa_accountbalance_freez t1 WHERE t1.sourcetable='sa_order' and t1.sourceid="+sa_orderid);
|
|
|
|
|
|
|
+ "WHERE t1.sa_accountbalanceid=" + accountbalancerows.get(0).getLong("sa_accountbalanceid") + " and t2.sourcetable='sa_order' and t2.sourceid=" + sa_orderid);
|
|
|
|
|
+ sqlList.add("delete from sa_accountbalance_freez t1 WHERE t1.sourcetable='sa_order' and t1.sourceid=" + sa_orderid);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
if (order_paymentnode.equals("3")) {
|
|
if (order_paymentnode.equals("3")) {
|
|
|
- CashbillEntity entity = getCashbillEntity(billRow.getBigDecimal("payamount").negate(), billRow.getBigDecimal("paydiscountamount").negate(), st_stockbillid, "销售出库单审核", billno, "由销售出库单" + billno + "审核时生成","货款");
|
|
|
|
|
|
|
+ CashbillEntity entity = getCashbillEntity(billRow.getString("billdate"),billRow.getBigDecimal("payamount").negate(), billRow.getBigDecimal("paydiscountamount").negate(), st_stockbillid, "销售出库单审核", billno, "由销售出库单" + billno + "审核时生成", "货款");
|
|
|
JSONObject createCashbillPay = Accountbalance.createCashbillPay(dbConnect, userInfo, sys_enterpriseid, accountbalancerows.get(0).getLong("sa_accountclassid"), entity, true);
|
|
JSONObject createCashbillPay = Accountbalance.createCashbillPay(dbConnect, userInfo, sys_enterpriseid, accountbalancerows.get(0).getLong("sa_accountclassid"), entity, true);
|
|
|
- if(!(billRow.getBigDecimal("payamount").compareTo(BigDecimal.ZERO)==0 && billRow.getBigDecimal("paydiscountamount").compareTo(BigDecimal.ZERO)==0)){
|
|
|
|
|
|
|
+ if (!(billRow.getBigDecimal("payamount").compareTo(BigDecimal.ZERO) == 0 && billRow.getBigDecimal("paydiscountamount").compareTo(BigDecimal.ZERO) == 0)) {
|
|
|
sqlList.addAll(createCashbillPay.getJSONArray("sqlList").toJavaList(String.class));
|
|
sqlList.addAll(createCashbillPay.getJSONArray("sqlList").toJavaList(String.class));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
- if(!billRow.getString("sourceobject").equals("tpartreimbursement")){
|
|
|
|
|
|
|
+ if (!billRow.getString("sourceobject").equals("tpartreimbursement")) {
|
|
|
Rows rowsOrderDetail = dbConnect.runSqlQuery("select t1.undeliqty,t1.deliedqty,t1.qty,t1.sa_orderitemsid from sa_orderitems t1 where t1.sa_orderitemsid in (select sa_orderitemsid from st_stockbill_items where sa_orderitemsid>0 and st_stockbillid=" + st_stockbillid + ")");
|
|
Rows rowsOrderDetail = dbConnect.runSqlQuery("select t1.undeliqty,t1.deliedqty,t1.qty,t1.sa_orderitemsid from sa_orderitems t1 where t1.sa_orderitemsid in (select sa_orderitemsid from st_stockbill_items where sa_orderitemsid>0 and st_stockbillid=" + st_stockbillid + ")");
|
|
|
RowsMap rowsMap = rowsOrderDetail.toRowsMap("sa_orderitemsid");
|
|
RowsMap rowsMap = rowsOrderDetail.toRowsMap("sa_orderitemsid");
|
|
|
Rows rowsDispatchDetailGroup = dbConnect.runSqlQuery("select sum(t1.qty) qty,t1.sa_orderitemsid,t1.siteid from st_stockbill_items t1 where t1.sa_orderitemsid>0 and t1.st_stockbillid=" + st_stockbillid + " group by t1.sa_orderitemsid,t1.siteid");
|
|
Rows rowsDispatchDetailGroup = dbConnect.runSqlQuery("select sum(t1.qty) qty,t1.sa_orderitemsid,t1.siteid from st_stockbill_items t1 where t1.sa_orderitemsid>0 and t1.st_stockbillid=" + st_stockbillid + " group by t1.sa_orderitemsid,t1.siteid");
|
|
|
for (Row row : rowsDispatchDetailGroup) {
|
|
for (Row row : rowsDispatchDetailGroup) {
|
|
|
sqlList.add("update sa_orderitems set undeliqty=" + rowsMap.get(row.getLong("sa_orderitemsid")).get(0).getBigDecimal("undeliqty").add(row.getBigDecimal("qty")) + ",deliedqty=" + (rowsMap.get(row.getLong("sa_orderitemsid")).get(0).getBigDecimal("deliedqty").subtract(row.getBigDecimal("qty"))) + " where sa_orderitemsid=" + row.getLong("sa_orderitemsid"));
|
|
sqlList.add("update sa_orderitems set undeliqty=" + rowsMap.get(row.getLong("sa_orderitemsid")).get(0).getBigDecimal("undeliqty").add(row.getBigDecimal("qty")) + ",deliedqty=" + (rowsMap.get(row.getLong("sa_orderitemsid")).get(0).getBigDecimal("deliedqty").subtract(row.getBigDecimal("qty"))) + " where sa_orderitemsid=" + row.getLong("sa_orderitemsid"));
|
|
|
|
|
|
|
|
- sqlList.add("update sa_orderitems set tobeoffqty=case when tobeoffqty-" + row.getDouble("qty") + ">0 then tobeoffqty-" + row.getDouble("qty")+" else 0 end where canoffqty>0 and sa_orderitemsid=" + row.getLong("sa_orderitemsid"));
|
|
|
|
|
|
|
+ sqlList.add("update sa_orderitems set tobeoffqty=case when tobeoffqty-" + row.getDouble("qty") + ">0 then tobeoffqty-" + row.getDouble("qty") + " else 0 end where canoffqty>0 and sa_orderitemsid=" + row.getLong("sa_orderitemsid"));
|
|
|
}
|
|
}
|
|
|
for (Row row : itemRows) {
|
|
for (Row row : itemRows) {
|
|
|
if (row.getBoolean("skucontrol")) {
|
|
if (row.getBoolean("skucontrol")) {
|
|
@@ -218,18 +218,18 @@ public class XSCK extends BasicBill {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
int orderautoclosepoint = Parameter.getInteger(siteid, "orderautoclosepoint");
|
|
int orderautoclosepoint = Parameter.getInteger(siteid, "orderautoclosepoint");
|
|
|
- if(orderautoclosepoint==2){
|
|
|
|
|
- ArrayList<Long> sa_orderids = itemRows.toArrayList("sa_orderid",new ArrayList<>());
|
|
|
|
|
- for(Long sa_orderid : sa_orderids){
|
|
|
|
|
- sqlList.add("update sa_order set status='审核',closeby='',closedate=NULL where sa_orderid=" +sa_orderid);
|
|
|
|
|
|
|
+ if (orderautoclosepoint == 2) {
|
|
|
|
|
+ ArrayList<Long> sa_orderids = itemRows.toArrayList("sa_orderid", new ArrayList<>());
|
|
|
|
|
+ for (Long sa_orderid : sa_orderids) {
|
|
|
|
|
+ sqlList.add("update sa_order set status='审核',closeby='',closedate=NULL where sa_orderid=" + sa_orderid);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- }else{
|
|
|
|
|
- QuerySQL querySQL = SQLFactory.createQuerySQL(controller, "sa_tpartreimbursementdetail", "sa_tpartreimbursementdetailid","isverified","qty","sa_orderitemsid");
|
|
|
|
|
|
|
+ } else {
|
|
|
|
|
+ QuerySQL querySQL = SQLFactory.createQuerySQL(controller, "sa_tpartreimbursementdetail", "sa_tpartreimbursementdetailid", "isverified", "qty", "sa_orderitemsid");
|
|
|
querySQL.setTableAlias("t1");
|
|
querySQL.setTableAlias("t1");
|
|
|
querySQL.addJoinTable(BaseClass.JOINTYPE.inner, "sa_tpartreimbursement", "t3", "t1.sa_tpartreimbursementid = t3.sa_tpartreimbursementid AND t1.siteid = t3.siteid");
|
|
querySQL.addJoinTable(BaseClass.JOINTYPE.inner, "sa_tpartreimbursement", "t3", "t1.sa_tpartreimbursementid = t3.sa_tpartreimbursementid AND t1.siteid = t3.siteid");
|
|
|
querySQL.setSiteid(siteid);
|
|
querySQL.setSiteid(siteid);
|
|
|
- querySQL.setWhere("t1.hongbillno='"+billno+"'");
|
|
|
|
|
|
|
+ querySQL.setWhere("t1.hongbillno='" + billno + "'");
|
|
|
|
|
|
|
|
Rows rows = querySQL.query();
|
|
Rows rows = querySQL.query();
|
|
|
|
|
|
|
@@ -239,7 +239,7 @@ public class XSCK extends BasicBill {
|
|
|
querySQLgroup.addJoinTable(BaseClass.JOINTYPE.left, "sa_orderitems", "t2", "t1.sa_orderitemsid = t2.sa_orderitemsid AND t1.siteid = t2.siteid");
|
|
querySQLgroup.addJoinTable(BaseClass.JOINTYPE.left, "sa_orderitems", "t2", "t1.sa_orderitemsid = t2.sa_orderitemsid AND t1.siteid = t2.siteid");
|
|
|
querySQLgroup.setSiteid(siteid);
|
|
querySQLgroup.setSiteid(siteid);
|
|
|
querySQLgroup.addQueryFields("sumqty", "sum(t1.checkqty)");
|
|
querySQLgroup.addQueryFields("sumqty", "sum(t1.checkqty)");
|
|
|
- querySQLgroup.setWhere("t1.hongbillno='"+ billno+"'");
|
|
|
|
|
|
|
+ querySQLgroup.setWhere("t1.hongbillno='" + billno + "'");
|
|
|
querySQLgroup.addGroupBy("sa_orderitemsid");
|
|
querySQLgroup.addGroupBy("sa_orderitemsid");
|
|
|
Rows rowsgroup = querySQLgroup.query();
|
|
Rows rowsgroup = querySQLgroup.query();
|
|
|
|
|
|
|
@@ -247,7 +247,7 @@ public class XSCK extends BasicBill {
|
|
|
sqlList.add("update sa_tpartreimbursementdetail set isverified=1 where sa_tpartreimbursementdetailid=" + row.getLong("sa_tpartreimbursementdetailid"));
|
|
sqlList.add("update sa_tpartreimbursementdetail set isverified=1 where sa_tpartreimbursementdetailid=" + row.getLong("sa_tpartreimbursementdetailid"));
|
|
|
}
|
|
}
|
|
|
for (Row row : rowsgroup) {
|
|
for (Row row : rowsgroup) {
|
|
|
- sqlList.add("update sa_orderitems set verifiedqty=ifnull(verifiedqty,0)+"+row.getBigDecimal("sumqty")+" where sa_orderitemsid=" + row.getLong("sa_orderitemsid"));
|
|
|
|
|
|
|
+ sqlList.add("update sa_orderitems set verifiedqty=ifnull(verifiedqty,0)+" + row.getBigDecimal("sumqty") + " where sa_orderitemsid=" + row.getLong("sa_orderitemsid"));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
@@ -259,10 +259,10 @@ public class XSCK extends BasicBill {
|
|
|
String order_paymentnode = Parameter.getString(siteid, "order_paymentnode");
|
|
String order_paymentnode = Parameter.getString(siteid, "order_paymentnode");
|
|
|
if (rb == 1) {
|
|
if (rb == 1) {
|
|
|
if (order_paymentnode.equals("3")) {
|
|
if (order_paymentnode.equals("3")) {
|
|
|
- Rows cashbillRows =dbConnect.runSqlQuery("select amount,discountamount from sa_cashbill where ownerid="+st_stockbillid +" and ownertable='st_stockbill' and type=0 and class='货款'");
|
|
|
|
|
- CashbillEntity entity = getCashbillEntity(cashbillRows.sum("amount").negate(), cashbillRows.sum("discountamount").negate(), st_stockbillid, "销售出库单反审核", billno, "由销售出库单" + billno + "反审核时生成","货款");
|
|
|
|
|
|
|
+ Rows cashbillRows = dbConnect.runSqlQuery("select amount,discountamount from sa_cashbill where ownerid=" + st_stockbillid + " and ownertable='st_stockbill' and type=0 and class='货款'");
|
|
|
|
|
+ CashbillEntity entity = getCashbillEntity(billRow.getString("billdate"),cashbillRows.sum("amount").negate(), cashbillRows.sum("discountamount").negate(), st_stockbillid, "销售出库单反审核", billno, "由销售出库单" + billno + "反审核时生成", "货款");
|
|
|
JSONObject createCashbillPay = Accountbalance.createCashbillPay(dbConnect, userInfo, sys_enterpriseid, accountbalancerows.get(0).getLong("sa_accountclassid"), entity, true);
|
|
JSONObject createCashbillPay = Accountbalance.createCashbillPay(dbConnect, userInfo, sys_enterpriseid, accountbalancerows.get(0).getLong("sa_accountclassid"), entity, true);
|
|
|
- if(!(cashbillRows.sum("amount").negate().compareTo(BigDecimal.ZERO)==0 && cashbillRows.sum("discountamount").negate().compareTo(BigDecimal.ZERO)==0)){
|
|
|
|
|
|
|
+ if (!(cashbillRows.sum("amount").negate().compareTo(BigDecimal.ZERO) == 0 && cashbillRows.sum("discountamount").negate().compareTo(BigDecimal.ZERO) == 0)) {
|
|
|
sqlList.addAll(createCashbillPay.getJSONArray("sqlList").toJavaList(String.class));
|
|
sqlList.addAll(createCashbillPay.getJSONArray("sqlList").toJavaList(String.class));
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -272,7 +272,7 @@ public class XSCK extends BasicBill {
|
|
|
for (Row row : rowsDispatchDetailGroup) {
|
|
for (Row row : rowsDispatchDetailGroup) {
|
|
|
sqlList.add("update sa_orderitems set undeliqty=" + rowsMap.get(row.getLong("sa_orderitemsid")).get(0).getBigDecimal("undeliqty").add(row.getBigDecimal("qty")) + ",deliedqty=" + (rowsMap.get(row.getLong("sa_orderitemsid")).get(0).getBigDecimal("deliedqty").subtract(row.getBigDecimal("qty"))) + " where sa_orderitemsid=" + row.getLong("sa_orderitemsid"));
|
|
sqlList.add("update sa_orderitems set undeliqty=" + rowsMap.get(row.getLong("sa_orderitemsid")).get(0).getBigDecimal("undeliqty").add(row.getBigDecimal("qty")) + ",deliedqty=" + (rowsMap.get(row.getLong("sa_orderitemsid")).get(0).getBigDecimal("deliedqty").subtract(row.getBigDecimal("qty"))) + " where sa_orderitemsid=" + row.getLong("sa_orderitemsid"));
|
|
|
|
|
|
|
|
- sqlList.add("update sa_orderitems set tobeoffqty=case when tobeoffqty-" + row.getDouble("qty") + ">0 then tobeoffqty-" + row.getDouble("qty")+" else 0 end where canoffqty>0 and sa_orderitemsid=" + row.getLong("sa_orderitemsid"));
|
|
|
|
|
|
|
+ sqlList.add("update sa_orderitems set tobeoffqty=case when tobeoffqty-" + row.getDouble("qty") + ">0 then tobeoffqty-" + row.getDouble("qty") + " else 0 end where canoffqty>0 and sa_orderitemsid=" + row.getLong("sa_orderitemsid"));
|
|
|
}
|
|
}
|
|
|
for (Row row : itemRows) {
|
|
for (Row row : itemRows) {
|
|
|
if (row.getBoolean("skucontrol")) {
|
|
if (row.getBoolean("skucontrol")) {
|
|
@@ -281,24 +281,24 @@ public class XSCK extends BasicBill {
|
|
|
}
|
|
}
|
|
|
//判断是否关闭订单
|
|
//判断是否关闭订单
|
|
|
int orderautoclosepoint = Parameter.getInteger(siteid, "orderautoclosepoint");
|
|
int orderautoclosepoint = Parameter.getInteger(siteid, "orderautoclosepoint");
|
|
|
- if(orderautoclosepoint==2){
|
|
|
|
|
- ArrayList<Long> sa_orderids = itemRows.toArrayList("sa_orderid",new ArrayList<>());
|
|
|
|
|
- for(Long sa_orderid : sa_orderids){
|
|
|
|
|
- sqlList.add("update sa_order set status='审核',closeby='',closedate=NULL where sa_orderid=" +sa_orderid);
|
|
|
|
|
|
|
+ if (orderautoclosepoint == 2) {
|
|
|
|
|
+ ArrayList<Long> sa_orderids = itemRows.toArrayList("sa_orderid", new ArrayList<>());
|
|
|
|
|
+ for (Long sa_orderid : sa_orderids) {
|
|
|
|
|
+ sqlList.add("update sa_order set status='审核',closeby='',closedate=NULL where sa_orderid=" + sa_orderid);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
sqlList.addAll(updateAccountbalance_freez(isInStock(ischeck)));
|
|
sqlList.addAll(updateAccountbalance_freez(isInStock(ischeck)));
|
|
|
} else {
|
|
} else {
|
|
|
if (order_paymentnode.equals("3")) {
|
|
if (order_paymentnode.equals("3")) {
|
|
|
- Rows cashbillRows =dbConnect.runSqlQuery("select amount,discountamount from sa_cashbill where ownerid="+st_stockbillid +" and ownertable='st_stockbill' and type=0 and class='货款'");
|
|
|
|
|
- CashbillEntity entity = getCashbillEntity(cashbillRows.sum("amount").negate(), cashbillRows.sum("discountamount").negate(), st_stockbillid, "销售出库单反审核", billno, "由销售出库单" + billno + "反审核时生成","货款");
|
|
|
|
|
|
|
+ Rows cashbillRows = dbConnect.runSqlQuery("select amount,discountamount from sa_cashbill where ownerid=" + st_stockbillid + " and ownertable='st_stockbill' and type=0 and class='货款'");
|
|
|
|
|
+ CashbillEntity entity = getCashbillEntity(billRow.getString("billdate"),cashbillRows.sum("amount").negate(), cashbillRows.sum("discountamount").negate(), st_stockbillid, "销售出库单反审核", billno, "由销售出库单" + billno + "反审核时生成", "货款");
|
|
|
JSONObject createCashbillPay = Accountbalance.createCashbillPay(dbConnect, userInfo, sys_enterpriseid, accountbalancerows.get(0).getLong("sa_accountclassid"), entity, true);
|
|
JSONObject createCashbillPay = Accountbalance.createCashbillPay(dbConnect, userInfo, sys_enterpriseid, accountbalancerows.get(0).getLong("sa_accountclassid"), entity, true);
|
|
|
- if(!(cashbillRows.sum("amount").negate().compareTo(BigDecimal.ZERO)==0 && cashbillRows.sum("discountamount").negate().compareTo(BigDecimal.ZERO)==0)){
|
|
|
|
|
|
|
+ if (!(cashbillRows.sum("amount").negate().compareTo(BigDecimal.ZERO) == 0 && cashbillRows.sum("discountamount").negate().compareTo(BigDecimal.ZERO) == 0)) {
|
|
|
sqlList.addAll(createCashbillPay.getJSONArray("sqlList").toJavaList(String.class));
|
|
sqlList.addAll(createCashbillPay.getJSONArray("sqlList").toJavaList(String.class));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
- if(!billRow.getString("sourceobject").equals("tpartreimbursement")){
|
|
|
|
|
|
|
+ if (!billRow.getString("sourceobject").equals("tpartreimbursement")) {
|
|
|
Rows rowsDispatchDetailGroup = dbConnect.runSqlQuery("select sum(t1.qty) qty,t1.sa_orderitemsid,t1.siteid from st_stockbill_items t1 where t1.sa_orderitemsid>0 and t1.st_stockbillid=" + st_stockbillid + " group by t1.sa_orderitemsid,t1.siteid");
|
|
Rows rowsDispatchDetailGroup = dbConnect.runSqlQuery("select sum(t1.qty) qty,t1.sa_orderitemsid,t1.siteid from st_stockbill_items t1 where t1.sa_orderitemsid>0 and t1.st_stockbillid=" + st_stockbillid + " group by t1.sa_orderitemsid,t1.siteid");
|
|
|
for (Row row : rowsDispatchDetailGroup) {
|
|
for (Row row : rowsDispatchDetailGroup) {
|
|
|
sqlList.add("update sa_orderitems set undeliqty=undeliqty-" + row.getDouble("qty") + ",deliedqty=ifnull(deliedqty,0)+" + row.getDouble("qty") + ",offstatus=if(billingstatus='保内收费','待核销','不可核销'),offdate=CURRENT_TIME where sa_orderitemsid=" + row.getLong("sa_orderitemsid"));
|
|
sqlList.add("update sa_orderitems set undeliqty=undeliqty-" + row.getDouble("qty") + ",deliedqty=ifnull(deliedqty,0)+" + row.getDouble("qty") + ",offstatus=if(billingstatus='保内收费','待核销','不可核销'),offdate=CURRENT_TIME where sa_orderitemsid=" + row.getLong("sa_orderitemsid"));
|
|
@@ -311,48 +311,48 @@ public class XSCK extends BasicBill {
|
|
|
}
|
|
}
|
|
|
//判断是否关闭订单
|
|
//判断是否关闭订单
|
|
|
int orderautoclosepoint = Parameter.getInteger(siteid, "orderautoclosepoint");
|
|
int orderautoclosepoint = Parameter.getInteger(siteid, "orderautoclosepoint");
|
|
|
- if(orderautoclosepoint==2){
|
|
|
|
|
- ArrayList<Long> sa_orderids = itemRows.toArrayList("sa_orderid",new ArrayList<>());
|
|
|
|
|
|
|
+ if (orderautoclosepoint == 2) {
|
|
|
|
|
+ ArrayList<Long> sa_orderids = itemRows.toArrayList("sa_orderid", new ArrayList<>());
|
|
|
QuerySQL querySQL = SQLFactory.createQuerySQL(controller, "sa_order", "sa_orderid");
|
|
QuerySQL querySQL = SQLFactory.createQuerySQL(controller, "sa_order", "sa_orderid");
|
|
|
querySQL.addJoinTable(BaseClass.JOINTYPE.inner, "sa_orderitems", "t2", "t2.sa_orderid = t1.sa_orderid and t2.siteid = t1.siteid",
|
|
querySQL.addJoinTable(BaseClass.JOINTYPE.inner, "sa_orderitems", "t2", "t2.sa_orderid = t1.sa_orderid and t2.siteid = t1.siteid",
|
|
|
- "undeliqty","sa_orderitemsid");
|
|
|
|
|
|
|
+ "undeliqty", "sa_orderitemsid");
|
|
|
querySQL.setTableAlias("t1");
|
|
querySQL.setTableAlias("t1");
|
|
|
querySQL.setWhere("t1.siteid", siteid);
|
|
querySQL.setWhere("t1.siteid", siteid);
|
|
|
querySQL.setWhere("t1.sa_orderid", sa_orderids);
|
|
querySQL.setWhere("t1.sa_orderid", sa_orderids);
|
|
|
querySQL.setWhere("t1.status='审核' and t2.undeliqty!=0");
|
|
querySQL.setWhere("t1.status='审核' and t2.undeliqty!=0");
|
|
|
Rows rows = querySQL.query();
|
|
Rows rows = querySQL.query();
|
|
|
- RowsMap rowsMap =rows.toRowsMap("sa_orderid");
|
|
|
|
|
- RowsMap itemRowsMap=itemRows.toRowsMap("sa_orderid");
|
|
|
|
|
- for(Long sa_orderid : sa_orderids){
|
|
|
|
|
- Rows stockbillitemrows = itemRowsMap.getOrDefault(String.valueOf(sa_orderid),new Rows());
|
|
|
|
|
- Rows orderrows = rowsMap.getOrDefault(String.valueOf(sa_orderid),new Rows());
|
|
|
|
|
- RowsMap stockbillitemrowsMap =stockbillitemrows.toRowsMap("sa_orderitemsid");
|
|
|
|
|
- int count=0;
|
|
|
|
|
- for(Row row : orderrows){
|
|
|
|
|
- if(stockbillitemrowsMap.containsKey(row.getString("sa_orderitemsid"))){
|
|
|
|
|
- if(stockbillitemrowsMap.getOrDefault(row.getString("sa_orderitemsid"),new Rows()).sum("qty").compareTo(row.getBigDecimal("undeliqty"))==0){
|
|
|
|
|
|
|
+ RowsMap rowsMap = rows.toRowsMap("sa_orderid");
|
|
|
|
|
+ RowsMap itemRowsMap = itemRows.toRowsMap("sa_orderid");
|
|
|
|
|
+ for (Long sa_orderid : sa_orderids) {
|
|
|
|
|
+ Rows stockbillitemrows = itemRowsMap.getOrDefault(String.valueOf(sa_orderid), new Rows());
|
|
|
|
|
+ Rows orderrows = rowsMap.getOrDefault(String.valueOf(sa_orderid), new Rows());
|
|
|
|
|
+ RowsMap stockbillitemrowsMap = stockbillitemrows.toRowsMap("sa_orderitemsid");
|
|
|
|
|
+ int count = 0;
|
|
|
|
|
+ for (Row row : orderrows) {
|
|
|
|
|
+ if (stockbillitemrowsMap.containsKey(row.getString("sa_orderitemsid"))) {
|
|
|
|
|
+ if (stockbillitemrowsMap.getOrDefault(row.getString("sa_orderitemsid"), new Rows()).sum("qty").compareTo(row.getBigDecimal("undeliqty")) == 0) {
|
|
|
count++;
|
|
count++;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if(orderrows.size()==count){
|
|
|
|
|
- sqlList.add("update sa_order set status='关闭',closeby='"+controller.username+"',closedate=CURRENT_TIME where sa_orderid=" +sa_orderid);
|
|
|
|
|
|
|
+ if (orderrows.size() == count) {
|
|
|
|
|
+ sqlList.add("update sa_order set status='关闭',closeby='" + controller.username + "',closedate=CURRENT_TIME where sa_orderid=" + sa_orderid);
|
|
|
sqlList.add("UPDATE sa_accountbalance t1 " +
|
|
sqlList.add("UPDATE sa_accountbalance t1 " +
|
|
|
"INNER JOIN sa_accountbalance_freez t2 ON t1.sa_accountbalanceid = t2.sa_accountbalanceid " +
|
|
"INNER JOIN sa_accountbalance_freez t2 ON t1.sa_accountbalanceid = t2.sa_accountbalanceid " +
|
|
|
"SET t1.freezamount = case when ifnull(t1.freezamount,0)>t2.amount then t1.freezamount-t2.amount else 0 end " +
|
|
"SET t1.freezamount = case when ifnull(t1.freezamount,0)>t2.amount then t1.freezamount-t2.amount else 0 end " +
|
|
|
- "WHERE t1.sa_accountbalanceid="+accountbalancerows.get(0).getLong("sa_accountbalanceid")+" and t2.sourcetable='sa_order' and t2.sourceid="+sa_orderid);
|
|
|
|
|
- sqlList.add("delete from sa_accountbalance_freez t1 WHERE t1.sourcetable='sa_order' and t1.sourceid="+sa_orderid);
|
|
|
|
|
|
|
+ "WHERE t1.sa_accountbalanceid=" + accountbalancerows.get(0).getLong("sa_accountbalanceid") + " and t2.sourcetable='sa_order' and t2.sourceid=" + sa_orderid);
|
|
|
|
|
+ sqlList.add("delete from sa_accountbalance_freez t1 WHERE t1.sourcetable='sa_order' and t1.sourceid=" + sa_orderid);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
- }else{
|
|
|
|
|
- QuerySQL querySQL = SQLFactory.createQuerySQL(controller, "sa_tpartreimbursementdetail", "sa_tpartreimbursementid","sa_tpartreimbursementdetailid","isverified","qty","sa_orderitemsid");
|
|
|
|
|
|
|
+ } else {
|
|
|
|
|
+ QuerySQL querySQL = SQLFactory.createQuerySQL(controller, "sa_tpartreimbursementdetail", "sa_tpartreimbursementid", "sa_tpartreimbursementdetailid", "isverified", "qty", "sa_orderitemsid");
|
|
|
querySQL.setTableAlias("t1");
|
|
querySQL.setTableAlias("t1");
|
|
|
querySQL.addJoinTable(BaseClass.JOINTYPE.inner, "sa_tpartreimbursement", "t3", "t1.sa_tpartreimbursementid = t3.sa_tpartreimbursementid AND t1.siteid = t3.siteid");
|
|
querySQL.addJoinTable(BaseClass.JOINTYPE.inner, "sa_tpartreimbursement", "t3", "t1.sa_tpartreimbursementid = t3.sa_tpartreimbursementid AND t1.siteid = t3.siteid");
|
|
|
querySQL.setSiteid(siteid);
|
|
querySQL.setSiteid(siteid);
|
|
|
- querySQL.setWhere("t1.hongbillno='"+billno+"'");
|
|
|
|
|
|
|
+ querySQL.setWhere("t1.hongbillno='" + billno + "'");
|
|
|
Rows rows = querySQL.query();
|
|
Rows rows = querySQL.query();
|
|
|
|
|
|
|
|
|
|
|
|
@@ -361,7 +361,7 @@ public class XSCK extends BasicBill {
|
|
|
querySQLgroup.addJoinTable(BaseClass.JOINTYPE.left, "sa_orderitems", "t2", "t1.sa_orderitemsid = t2.sa_orderitemsid AND t1.siteid = t2.siteid");
|
|
querySQLgroup.addJoinTable(BaseClass.JOINTYPE.left, "sa_orderitems", "t2", "t1.sa_orderitemsid = t2.sa_orderitemsid AND t1.siteid = t2.siteid");
|
|
|
querySQLgroup.setSiteid(siteid);
|
|
querySQLgroup.setSiteid(siteid);
|
|
|
querySQLgroup.addQueryFields("sumqty", "sum(t1.checkqty)");
|
|
querySQLgroup.addQueryFields("sumqty", "sum(t1.checkqty)");
|
|
|
- querySQLgroup.setWhere("t1.hongbillno='"+ billno+"'");
|
|
|
|
|
|
|
+ querySQLgroup.setWhere("t1.hongbillno='" + billno + "'");
|
|
|
querySQLgroup.addGroupBy("sa_orderitemsid");
|
|
querySQLgroup.addGroupBy("sa_orderitemsid");
|
|
|
Rows rowsgroup = querySQLgroup.query();
|
|
Rows rowsgroup = querySQLgroup.query();
|
|
|
|
|
|
|
@@ -370,7 +370,7 @@ public class XSCK extends BasicBill {
|
|
|
sqlList.add("update sa_tpartreimbursement set status='审核' where sa_tpartreimbursementid=" + row.getLong("sa_tpartreimbursementid"));
|
|
sqlList.add("update sa_tpartreimbursement set status='审核' where sa_tpartreimbursementid=" + row.getLong("sa_tpartreimbursementid"));
|
|
|
}
|
|
}
|
|
|
for (Row row : rowsgroup) {
|
|
for (Row row : rowsgroup) {
|
|
|
- sqlList.add("update sa_orderitems set verifiedqty=ifnull(verifiedqty,0)-"+row.getBigDecimal("sumqty")+" where sa_orderitemsid=" + row.getLong("sa_orderitemsid"));
|
|
|
|
|
|
|
+ sqlList.add("update sa_orderitems set verifiedqty=ifnull(verifiedqty,0)-" + row.getBigDecimal("sumqty") + " where sa_orderitemsid=" + row.getLong("sa_orderitemsid"));
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -390,14 +390,14 @@ public class XSCK extends BasicBill {
|
|
|
String order_paymentnode = Parameter.getString(siteid, "order_paymentnode");
|
|
String order_paymentnode = Parameter.getString(siteid, "order_paymentnode");
|
|
|
if (rb == 1) {
|
|
if (rb == 1) {
|
|
|
if (order_paymentnode.equals("3")) {
|
|
if (order_paymentnode.equals("3")) {
|
|
|
- BigDecimal custamount=BigDecimal.ZERO;
|
|
|
|
|
- for(Row row :itemRows){
|
|
|
|
|
- custamount=custamount.add(row.getBigDecimal("custamount").multiply(row.getBigDecimal("qty")));
|
|
|
|
|
|
|
+ BigDecimal custamount = BigDecimal.ZERO;
|
|
|
|
|
+ for (Row row : itemRows) {
|
|
|
|
|
+ custamount = custamount.add(row.getBigDecimal("custamount").multiply(row.getBigDecimal("qty")));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- CashbillEntity entity_custamount = getCashbillEntity(custamount, BigDecimal.ZERO, st_stockbillid, "销售出库单审核", billno, "由销售出库单" + billno + "审核时生成","客户档案资料费");
|
|
|
|
|
|
|
+ CashbillEntity entity_custamount = getCashbillEntity(billRow.getString("billdate"),custamount, BigDecimal.ZERO, st_stockbillid, "销售出库单审核", billno, "由销售出库单" + billno + "审核时生成", "客户档案资料费");
|
|
|
JSONObject createCashbillPay_custamount = Accountbalance.createCashbillPay(dbConnect, userInfo, sys_enterpriseid, accountbalancerows.get(0).getLong("sa_accountclassid"), entity_custamount, true);
|
|
JSONObject createCashbillPay_custamount = Accountbalance.createCashbillPay(dbConnect, userInfo, sys_enterpriseid, accountbalancerows.get(0).getLong("sa_accountclassid"), entity_custamount, true);
|
|
|
- if(custamount.compareTo(BigDecimal.ZERO)!=0){
|
|
|
|
|
|
|
+ if (custamount.compareTo(BigDecimal.ZERO) != 0) {
|
|
|
sqlList.addAll(createCashbillPay_custamount.getJSONArray("sqlList").toJavaList(String.class));
|
|
sqlList.addAll(createCashbillPay_custamount.getJSONArray("sqlList").toJavaList(String.class));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -405,13 +405,13 @@ public class XSCK extends BasicBill {
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
if (order_paymentnode.equals("3")) {
|
|
if (order_paymentnode.equals("3")) {
|
|
|
- BigDecimal custamount=BigDecimal.ZERO;
|
|
|
|
|
- for(Row row :itemRows){
|
|
|
|
|
- custamount=custamount.add(row.getBigDecimal("custamount").multiply(row.getBigDecimal("qty")));
|
|
|
|
|
|
|
+ BigDecimal custamount = BigDecimal.ZERO;
|
|
|
|
|
+ for (Row row : itemRows) {
|
|
|
|
|
+ custamount = custamount.add(row.getBigDecimal("custamount").multiply(row.getBigDecimal("qty")));
|
|
|
}
|
|
}
|
|
|
- CashbillEntity entity_custamount = getCashbillEntity(custamount.negate(), BigDecimal.ZERO, st_stockbillid, "销售出库单审核", billno, "由销售出库单" + billno + "审核时生成","客户档案资料费");
|
|
|
|
|
|
|
+ CashbillEntity entity_custamount = getCashbillEntity(billRow.getString("billdate"),custamount.negate(), BigDecimal.ZERO, st_stockbillid, "销售出库单审核", billno, "由销售出库单" + billno + "审核时生成", "客户档案资料费");
|
|
|
JSONObject createCashbillPay_custamount = Accountbalance.createCashbillPay(dbConnect, userInfo, sys_enterpriseid, accountbalancerows.get(0).getLong("sa_accountclassid"), entity_custamount, true);
|
|
JSONObject createCashbillPay_custamount = Accountbalance.createCashbillPay(dbConnect, userInfo, sys_enterpriseid, accountbalancerows.get(0).getLong("sa_accountclassid"), entity_custamount, true);
|
|
|
- if(custamount.negate().compareTo(BigDecimal.ZERO)!=0){
|
|
|
|
|
|
|
+ if (custamount.negate().compareTo(BigDecimal.ZERO) != 0) {
|
|
|
sqlList.addAll(createCashbillPay_custamount.getJSONArray("sqlList").toJavaList(String.class));
|
|
sqlList.addAll(createCashbillPay_custamount.getJSONArray("sqlList").toJavaList(String.class));
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -421,19 +421,19 @@ public class XSCK extends BasicBill {
|
|
|
String order_paymentnode = Parameter.getString(siteid, "order_paymentnode");
|
|
String order_paymentnode = Parameter.getString(siteid, "order_paymentnode");
|
|
|
if (rb == 1) {
|
|
if (rb == 1) {
|
|
|
if (order_paymentnode.equals("3")) {
|
|
if (order_paymentnode.equals("3")) {
|
|
|
- Rows cashbillRows_custamount =dbConnect.runSqlQuery("select amount,discountamount from sa_cashbill where ownerid="+st_stockbillid +" and ownertable='st_stockbill' and type=0 and class='客户档案资料费'");
|
|
|
|
|
- CashbillEntity entity_custamount = getCashbillEntity(cashbillRows_custamount.sum("amount").negate(), cashbillRows_custamount.sum("discountamount").negate(), st_stockbillid, "销售出库单反审核", billno, "由销售出库单" + billno + "反审核时生成","客户档案资料费");
|
|
|
|
|
|
|
+ Rows cashbillRows_custamount = dbConnect.runSqlQuery("select amount,discountamount from sa_cashbill where ownerid=" + st_stockbillid + " and ownertable='st_stockbill' and type=0 and class='客户档案资料费'");
|
|
|
|
|
+ CashbillEntity entity_custamount = getCashbillEntity(billRow.getString("billdate"),cashbillRows_custamount.sum("amount").negate(), cashbillRows_custamount.sum("discountamount").negate(), st_stockbillid, "销售出库单反审核", billno, "由销售出库单" + billno + "反审核时生成", "客户档案资料费");
|
|
|
JSONObject createCashbillPay_custamount = Accountbalance.createCashbillPay(dbConnect, userInfo, sys_enterpriseid, accountbalancerows.get(0).getLong("sa_accountclassid"), entity_custamount, true);
|
|
JSONObject createCashbillPay_custamount = Accountbalance.createCashbillPay(dbConnect, userInfo, sys_enterpriseid, accountbalancerows.get(0).getLong("sa_accountclassid"), entity_custamount, true);
|
|
|
- if(cashbillRows_custamount.sum("amount").negate().compareTo(BigDecimal.ZERO)!=0){
|
|
|
|
|
|
|
+ if (cashbillRows_custamount.sum("amount").negate().compareTo(BigDecimal.ZERO) != 0) {
|
|
|
sqlList.addAll(createCashbillPay_custamount.getJSONArray("sqlList").toJavaList(String.class));
|
|
sqlList.addAll(createCashbillPay_custamount.getJSONArray("sqlList").toJavaList(String.class));
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
if (order_paymentnode.equals("3")) {
|
|
if (order_paymentnode.equals("3")) {
|
|
|
- Rows cashbillRows_custamount =dbConnect.runSqlQuery("select amount,discountamount from sa_cashbill where ownerid="+st_stockbillid +" and ownertable='st_stockbill' and type=0 and class='客户档案资料费'");
|
|
|
|
|
- CashbillEntity entity_custamount = getCashbillEntity(cashbillRows_custamount.sum("amount").negate(),cashbillRows_custamount.sum("discountamount").negate(), st_stockbillid, "销售出库单审核", billno, "由销售出库单" + billno + "审核时生成","客户档案资料费");
|
|
|
|
|
|
|
+ Rows cashbillRows_custamount = dbConnect.runSqlQuery("select amount,discountamount from sa_cashbill where ownerid=" + st_stockbillid + " and ownertable='st_stockbill' and type=0 and class='客户档案资料费'");
|
|
|
|
|
+ CashbillEntity entity_custamount = getCashbillEntity(billRow.getString("billdate"),cashbillRows_custamount.sum("amount").negate(), cashbillRows_custamount.sum("discountamount").negate(), st_stockbillid, "销售出库单审核", billno, "由销售出库单" + billno + "审核时生成", "客户档案资料费");
|
|
|
JSONObject createCashbillPay_custamount = Accountbalance.createCashbillPay(dbConnect, userInfo, sys_enterpriseid, accountbalancerows.get(0).getLong("sa_accountclassid"), entity_custamount, true);
|
|
JSONObject createCashbillPay_custamount = Accountbalance.createCashbillPay(dbConnect, userInfo, sys_enterpriseid, accountbalancerows.get(0).getLong("sa_accountclassid"), entity_custamount, true);
|
|
|
- if(cashbillRows_custamount.sum("amount").negate().compareTo(BigDecimal.ZERO)!=0){
|
|
|
|
|
|
|
+ if (cashbillRows_custamount.sum("amount").negate().compareTo(BigDecimal.ZERO) != 0) {
|
|
|
sqlList.addAll(createCashbillPay_custamount.getJSONArray("sqlList").toJavaList(String.class));
|
|
sqlList.addAll(createCashbillPay_custamount.getJSONArray("sqlList").toJavaList(String.class));
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -476,7 +476,7 @@ public class XSCK extends BasicBill {
|
|
|
insertSQL.setValue("sourcetable", "sa_order");
|
|
insertSQL.setValue("sourcetable", "sa_order");
|
|
|
insertSQL.setValue("sourceid", sa_orderid);
|
|
insertSQL.setValue("sourceid", sa_orderid);
|
|
|
insertSQL.setValue("amount", amount);
|
|
insertSQL.setValue("amount", amount);
|
|
|
- insertSQL.setValue("remarks", "由"+ (row.getString("type").equals("配件订单")?"配件":"销售")+"订单" + sonum + "审核时冻结");
|
|
|
|
|
|
|
+ insertSQL.setValue("remarks", "由" + (row.getString("type").equals("配件订单") ? "配件" : "销售") + "订单" + sonum + "审核时冻结");
|
|
|
insertSQL.setValue("createby", userInfo.getUserName());
|
|
insertSQL.setValue("createby", userInfo.getUserName());
|
|
|
insertSQL.setDateValue("createdate");
|
|
insertSQL.setDateValue("createdate");
|
|
|
sqllist.add(insertSQL.getSQL());
|
|
sqllist.add(insertSQL.getSQL());
|
|
@@ -489,10 +489,10 @@ public class XSCK extends BasicBill {
|
|
|
BigDecimal amount = row.getBigDecimal("amount");
|
|
BigDecimal amount = row.getBigDecimal("amount");
|
|
|
Rows accountbalancefreezrows = dbConnect.runSqlQuery("select sa_accountbalance_freezid,amount from sa_accountbalance_freez where sourceid=" + sa_orderid + " and sourcetable='sa_order' and siteid='" + siteid + "'");
|
|
Rows accountbalancefreezrows = dbConnect.runSqlQuery("select sa_accountbalance_freezid,amount from sa_accountbalance_freez where sourceid=" + sa_orderid + " and sourcetable='sa_order' and siteid='" + siteid + "'");
|
|
|
if (accountbalancefreezrows.size() > 0) {
|
|
if (accountbalancefreezrows.size() > 0) {
|
|
|
- if(accountbalancefreezrows.get(0).getBigDecimal("amount").compareTo(amount)>0){
|
|
|
|
|
|
|
+ if (accountbalancefreezrows.get(0).getBigDecimal("amount").compareTo(amount) > 0) {
|
|
|
sqllist.add("update sa_accountbalance set freezamount=ifnull(freezamount,0)-" + amount + " where sa_accountbalanceid=" + sa_accountbalanceid);
|
|
sqllist.add("update sa_accountbalance set freezamount=ifnull(freezamount,0)-" + amount + " where sa_accountbalanceid=" + sa_accountbalanceid);
|
|
|
sqllist.add("update sa_accountbalance_freez set amount=amount-" + amount + " where sa_accountbalance_freezid=" + accountbalancefreezrows.get(0).getLong("sa_accountbalance_freezid"));
|
|
sqllist.add("update sa_accountbalance_freez set amount=amount-" + amount + " where sa_accountbalance_freezid=" + accountbalancefreezrows.get(0).getLong("sa_accountbalance_freezid"));
|
|
|
- }else{
|
|
|
|
|
|
|
+ } else {
|
|
|
sqllist.add("update sa_accountbalance set freezamount=ifnull(freezamount,0)-" + accountbalancefreezrows.get(0).getBigDecimal("amount") + " where sa_accountbalanceid=" + sa_accountbalanceid);
|
|
sqllist.add("update sa_accountbalance set freezamount=ifnull(freezamount,0)-" + accountbalancefreezrows.get(0).getBigDecimal("amount") + " where sa_accountbalanceid=" + sa_accountbalanceid);
|
|
|
sqllist.add("update sa_accountbalance_freez set amount=0 where sa_accountbalance_freezid=" + accountbalancefreezrows.get(0).getLong("sa_accountbalance_freezid"));
|
|
sqllist.add("update sa_accountbalance_freez set amount=0 where sa_accountbalance_freezid=" + accountbalancefreezrows.get(0).getLong("sa_accountbalance_freezid"));
|
|
|
}
|
|
}
|
|
@@ -504,8 +504,8 @@ public class XSCK extends BasicBill {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
- public static CashbillEntity getCashbillEntity(BigDecimal amount, BigDecimal discountamount, Long ownerid, String source, String sourcenotes, String remarks,String type) throws YosException {
|
|
|
|
|
- CashbillEntity entity = new CashbillEntity();
|
|
|
|
|
|
|
+ public static CashbillEntity getCashbillEntity(String billdate, BigDecimal amount, BigDecimal discountamount, Long ownerid, String source, String sourcenotes, String remarks, String type) throws YosException {
|
|
|
|
|
+ CashbillEntity entity = new CashbillEntity(billdate);
|
|
|
entity.setAmount(amount);
|
|
entity.setAmount(amount);
|
|
|
entity.setDiscountamountamount(discountamount);
|
|
entity.setDiscountamountamount(discountamount);
|
|
|
entity.setOwnerid(ownerid);
|
|
entity.setOwnerid(ownerid);
|