|
|
@@ -644,6 +644,7 @@ public class Order extends Controller {
|
|
|
QuerySQL expressformQuery = SQLFactory.createQuerySQL(this, "expressform", "*").setTableAlias("t1");
|
|
|
expressformQuery.addJoinTable(JOINTYPE.inner, "sa_expressform_stockbill", "t2", "t2.expressformid = t1.expressformid");
|
|
|
expressformQuery.addJoinTable(JOINTYPE.inner, "st_stockbill_items", "t3", "t3.st_stockbillid = t2.st_stockbillid","sa_orderid");
|
|
|
+ expressformQuery.addJoinTable(JOINTYPE.inner, "st_stockbill", "t4", "t3.st_stockbillid = t4.st_stockbillid","tracknumber");
|
|
|
expressformQuery.setWhere("t3.sa_orderid", sa_orderids);
|
|
|
expressformQuery.setOrderBy("t1.createdate desc");
|
|
|
expressformQuery.setDistinct(true);
|
|
|
@@ -1608,7 +1609,7 @@ public class Order extends Controller {
|
|
|
}
|
|
|
|
|
|
Row orderRow = rows.get(0);
|
|
|
- Rows departmenthrrows =dbConnect.runSqlQuery("select *from sys_departmenthrid where hrid="+hrid);
|
|
|
+ Rows departmenthrrows =dbConnect.runSqlQuery("select t1.*,t2.depname from sys_departmenthrid t1 left join sys_department t2 on t1.departmentid=t2.departmentid where t1.hrid="+hrid);
|
|
|
|
|
|
long st_stockbillid = createTableID("st_stockbill");
|
|
|
InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "st_stockbill");
|
|
|
@@ -1694,7 +1695,28 @@ public class Order extends Controller {
|
|
|
sqlList.add(insertSQL.getSQL());
|
|
|
}
|
|
|
dbConnect.runSqlUpdate(sqlList);
|
|
|
- dbConnect.runSqlUpdate("update st_stockbill set payamount="+payamount+" where st_stockbillid="+st_stockbillid);
|
|
|
+
|
|
|
+ String depname= departmenthrrows.isNotEmpty()?departmenthrrows.get(0).getString("depname"):"";
|
|
|
+ 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"));
|
|
|
+ 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+" 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);
|
|
|
return getSucReturnObject().setData(st_stockbillid).toString();
|
|
|
}
|
|
|
@@ -1746,7 +1768,7 @@ public class Order extends Controller {
|
|
|
}
|
|
|
}
|
|
|
Row orderRow = rows.get(0);
|
|
|
- Rows departmenthrrows =dbConnect.runSqlQuery("select *from sys_departmenthrid where hrid="+hrid);
|
|
|
+ Rows departmenthrrows =dbConnect.runSqlQuery("select t1.*,t2.depname from sys_departmenthrid t1 left join sys_department t2 on t1.departmentid=t2.departmentid where t1.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");
|
|
|
@@ -1832,21 +1854,28 @@ public class Order extends Controller {
|
|
|
sqlList.add(insertSQL.getSQL());
|
|
|
}
|
|
|
dbConnect.runSqlUpdate(sqlList);
|
|
|
- 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="+accountbalancerows.get(0).getBigDecimal("discountamount")+" where st_stockbillid="+st_stockbillid);
|
|
|
+
|
|
|
+ String depname= departmenthrrows.isNotEmpty()?departmenthrrows.get(0).getString("depname"):"";
|
|
|
+ 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.subtract(accountbalancerows.get(0).getBigDecimal("discountamount"))+",paydiscountamount="+accountbalancerows.get(0).getBigDecimal("discountamount")+" where st_stockbillid="+st_stockbillid);
|
|
|
+ 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);
|
|
|
}
|
|
|
-
|
|
|
}else{
|
|
|
dbConnect.runSqlUpdate("update st_stockbill set payamount="+payamount+" where st_stockbillid="+st_stockbillid);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
content.put("st_stockbillid",st_stockbillid);
|
|
|
return getSucReturnObject().setData(st_stockbillid).toString();
|
|
|
}
|
|
|
@@ -2017,7 +2046,7 @@ public class Order extends Controller {
|
|
|
Rows accountbalancerows =accountbalanceQuerySQL.query();
|
|
|
RowsMap accountbalancerowsMap = accountbalancerows.toRowsMap("sys_enterpriseid");
|
|
|
|
|
|
- Rows departmenthrrows =dbConnect.runSqlQuery("select *from sys_departmenthrid where hrid="+hrid);
|
|
|
+ Rows departmenthrrows =dbConnect.runSqlQuery("select t1.*,t2.depname from sys_departmenthrid t1 left join sys_department t2 on t1.departmentid=t2.departmentid where t1.hrid="+hrid);
|
|
|
for(String sys_enterpriseid :enterpriseSet){
|
|
|
for(String delivery:deliverySet){
|
|
|
if(enterpriserowsMap.get(sys_enterpriseid).toRowsMap("delivery").containsKey(delivery)){
|
|
|
@@ -2101,13 +2130,17 @@ public class Order extends Controller {
|
|
|
i++;
|
|
|
sqlList.add(insertSQL.getSQL());
|
|
|
}
|
|
|
-
|
|
|
- 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,paydiscountamount="+accountbalancerowsMap.get(sys_enterpriseid).get(0).getBigDecimal("discountamount")+" where st_stockbillid="+st_stockbillid);
|
|
|
+ String depname= departmenthrrows.isNotEmpty()?departmenthrrows.get(0).getString("depname"):"";
|
|
|
+ if(depname.equals("售后部")){
|
|
|
+ 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,paydiscountamount="+payamount+" where st_stockbillid="+st_stockbillid);
|
|
|
+ }else{
|
|
|
+ sqlList.add("update st_stockbill set payamount="+payamount.subtract(accountbalancerowsMap.get(sys_enterpriseid).get(0).getBigDecimal("discountamount"))+",paydiscountamount="+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"))+",paydiscountamount="+accountbalancerowsMap.get(sys_enterpriseid).get(0).getBigDecimal("discountamount")+" where st_stockbillid="+st_stockbillid);
|
|
|
+ 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);
|
|
|
@@ -2115,6 +2148,8 @@ public class Order extends Controller {
|
|
|
}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++;
|
|
|
}
|