|
@@ -1724,6 +1724,8 @@ public class Order extends Controller {
|
|
|
querySQL.setWhere("t1.sa_orderitemsid",sa_orderitemsids);
|
|
querySQL.setWhere("t1.sa_orderitemsid",sa_orderitemsids);
|
|
|
Rows rowsdetail = querySQL.query();
|
|
Rows rowsdetail = querySQL.query();
|
|
|
Row orderRow = rows.get(0);
|
|
Row orderRow = rows.get(0);
|
|
|
|
|
+ Rows departmenthrrows =dbConnect.runSqlQuery("select *from sys_departmenthrid where hrid="+hrid);
|
|
|
|
|
+ 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=" + orderRow.getLong("sys_enterpriseid"));
|
|
|
|
|
|
|
|
long st_stockbillid = createTableID("st_stockbill");
|
|
long st_stockbillid = createTableID("st_stockbill");
|
|
|
InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "st_stockbill");
|
|
InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "st_stockbill");
|
|
@@ -1731,7 +1733,7 @@ public class Order extends Controller {
|
|
|
insertSQL.setSiteid(siteid);
|
|
insertSQL.setSiteid(siteid);
|
|
|
insertSQL.setValue("sys_enterpriseid", orderRow.getLong("sys_enterpriseid"));
|
|
insertSQL.setValue("sys_enterpriseid", orderRow.getLong("sys_enterpriseid"));
|
|
|
insertSQL.setValue("rec_contactsid", orderRow.getLong("rec_contactsid"));
|
|
insertSQL.setValue("rec_contactsid", orderRow.getLong("rec_contactsid"));
|
|
|
- insertSQL.setValue("departmentid", 0);
|
|
|
|
|
|
|
+ insertSQL.setValue("departmentid", departmenthrrows.isNotEmpty()?departmenthrrows.get(0).getLong("departmentid"):0);
|
|
|
insertSQL.setValue("stockid", 0);
|
|
insertSQL.setValue("stockid", 0);
|
|
|
insertSQL.setValue("type", "销售出库");
|
|
insertSQL.setValue("type", "销售出库");
|
|
|
insertSQL.setValue("typemx", "");
|
|
insertSQL.setValue("typemx", "");
|
|
@@ -1791,7 +1793,21 @@ public class Order extends Controller {
|
|
|
sqlList.add(insertSQL.getSQL());
|
|
sqlList.add(insertSQL.getSQL());
|
|
|
}
|
|
}
|
|
|
dbConnect.runSqlUpdate(sqlList);
|
|
dbConnect.runSqlUpdate(sqlList);
|
|
|
- dbConnect.runSqlUpdate("update st_stockbill set payamount="+payamount+" where st_stockbillid="+st_stockbillid);
|
|
|
|
|
|
|
+ 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,discountamount="+accountbalancerows.get(0).getBigDecimal("discountamount")+" where st_stockbillid="+st_stockbillid);
|
|
|
|
|
+ }else{
|
|
|
|
|
+ dbConnect.runSqlUpdate("update st_stockbill set payamount="+payamount.subtract(accountbalancerows.get(0).getBigDecimal("discountamount"))+",discountamount="+accountbalancerows.get(0).getBigDecimal("discountamount")+" where st_stockbillid="+st_stockbillid);
|
|
|
|
|
+ }
|
|
|
|
|
+ }else{
|
|
|
|
|
+ dbConnect.runSqlUpdate("update st_stockbill set payamount="+payamount+" where st_stockbillid="+st_stockbillid);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }else{
|
|
|
|
|
+ dbConnect.runSqlUpdate("update st_stockbill set payamount="+payamount+" where st_stockbillid="+st_stockbillid);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
content.put("st_stockbillid",st_stockbillid);
|
|
content.put("st_stockbillid",st_stockbillid);
|
|
|
return getSucReturnObject().setData(st_stockbillid).toString();
|
|
return getSucReturnObject().setData(st_stockbillid).toString();
|
|
|
}
|
|
}
|
|
@@ -1939,6 +1955,17 @@ public class Order extends Controller {
|
|
|
Set<String> enterpriseSet = enterpriserowsMap.keySet();
|
|
Set<String> enterpriseSet = enterpriserowsMap.keySet();
|
|
|
Set<String> deliverySet = deliveryrowsMap.keySet();
|
|
Set<String> deliverySet = deliveryrowsMap.keySet();
|
|
|
int stockbillcount=0;
|
|
int stockbillcount=0;
|
|
|
|
|
+
|
|
|
|
|
+ QuerySQL accountbalanceQuerySQL = SQLFactory.createQuerySQL(this, "sa_accountbalance","*");
|
|
|
|
|
+ accountbalanceQuerySQL.setTableAlias("t1");
|
|
|
|
|
+ accountbalanceQuerySQL.addJoinTable(JOINTYPE.inner, "sa_accountclass", "t2", "t1.sa_accountclassid=t2.sa_accountclassid and t1.siteid=t2.siteid");
|
|
|
|
|
+ accountbalanceQuerySQL.setWhere("t1.siteid",siteid);
|
|
|
|
|
+ accountbalanceQuerySQL.setWhere("t2.accountname='现金账户'");
|
|
|
|
|
+ accountbalanceQuerySQL.setWhere("t1.sys_enterpriseid",orderRows_result.toArrayList("sys_enterpriseid"));
|
|
|
|
|
+ Rows accountbalancerows =accountbalanceQuerySQL.query();
|
|
|
|
|
+ RowsMap accountbalancerowsMap = accountbalancerows.toRowsMap("sys_enterpriseid");
|
|
|
|
|
+
|
|
|
|
|
+ Rows departmenthrrows =dbConnect.runSqlQuery("select *from sys_departmenthrid where hrid="+hrid);
|
|
|
for(String sys_enterpriseid :enterpriseSet){
|
|
for(String sys_enterpriseid :enterpriseSet){
|
|
|
for(String delivery:deliverySet){
|
|
for(String delivery:deliverySet){
|
|
|
if(enterpriserowsMap.get(sys_enterpriseid).toRowsMap("delivery").containsKey(delivery)){
|
|
if(enterpriserowsMap.get(sys_enterpriseid).toRowsMap("delivery").containsKey(delivery)){
|
|
@@ -1949,7 +1976,7 @@ public class Order extends Controller {
|
|
|
insertSQL.setSiteid(siteid);
|
|
insertSQL.setSiteid(siteid);
|
|
|
insertSQL.setValue("sys_enterpriseid", sys_enterpriseid);
|
|
insertSQL.setValue("sys_enterpriseid", sys_enterpriseid);
|
|
|
insertSQL.setValue("rec_contactsid", orderdetailRows.get(0).getLong("rec_contactsid"));
|
|
insertSQL.setValue("rec_contactsid", orderdetailRows.get(0).getLong("rec_contactsid"));
|
|
|
- insertSQL.setValue("departmentid", 0);
|
|
|
|
|
|
|
+ insertSQL.setValue("departmentid", departmenthrrows.isNotEmpty()?departmenthrrows.get(0).getLong("departmentid"):0);
|
|
|
insertSQL.setValue("stockid", 0);
|
|
insertSQL.setValue("stockid", 0);
|
|
|
insertSQL.setValue("type", "销售出库");
|
|
insertSQL.setValue("type", "销售出库");
|
|
|
insertSQL.setValue("typemx", "");
|
|
insertSQL.setValue("typemx", "");
|
|
@@ -2008,7 +2035,21 @@ public class Order extends Controller {
|
|
|
i++;
|
|
i++;
|
|
|
sqlList.add(insertSQL.getSQL());
|
|
sqlList.add(insertSQL.getSQL());
|
|
|
}
|
|
}
|
|
|
- sqlList.add("update st_stockbill set payamount="+payamount+" where st_stockbillid="+st_stockbillid);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if(accountbalancerowsMap.containsKey(sys_enterpriseid)){
|
|
|
|
|
+ if(accountbalancerowsMap.get(sys_enterpriseid).get(0).getBigDecimal("discountamount").compareTo(BigDecimal.ZERO)>0){
|
|
|
|
|
+ if(accountbalancerowsMap.get(sys_enterpriseid).get(0).getBigDecimal("discountamount").compareTo(payamount)>0){
|
|
|
|
|
+ sqlList.add("update st_stockbill set payamount=0,discountamount="+accountbalancerowsMap.get(sys_enterpriseid).get(0).getBigDecimal("discountamount")+" where st_stockbillid="+st_stockbillid);
|
|
|
|
|
+ }else{
|
|
|
|
|
+ sqlList.add("update st_stockbill set payamount="+payamount.subtract(accountbalancerowsMap.get(sys_enterpriseid).get(0).getBigDecimal("discountamount"))+",discountamount="+accountbalancerowsMap.get(sys_enterpriseid).get(0).getBigDecimal("discountamount")+" where st_stockbillid="+st_stockbillid);
|
|
|
|
|
+ }
|
|
|
|
|
+ }else{
|
|
|
|
|
+ sqlList.add("update st_stockbill set payamount="+payamount+" where st_stockbillid="+st_stockbillid);
|
|
|
|
|
+ }
|
|
|
|
|
+ }else{
|
|
|
|
|
+ sqlList.add("update st_stockbill set payamount="+payamount+" where st_stockbillid="+st_stockbillid);
|
|
|
|
|
+ }
|
|
|
|
|
+// sqlList.add("update st_stockbill set payamount="+payamount+" where st_stockbillid="+st_stockbillid);
|
|
|
stockbillcount++;
|
|
stockbillcount++;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|