eganwu пре 1 година
родитељ
комит
b6e2609935

+ 13 - 3
src/custom/function/OrderFeeCalculatePlan1.java

@@ -45,6 +45,7 @@ public class OrderFeeCalculatePlan1 extends DataFunction {
     @Override
     public int action() throws YosException {
         //判断当前订单类型是否满足方案
+        System.err.println("start......");
         Row orderRow = Order.getOrderRows(controller, sa_orderid).get(0);
         String type = orderRow.getString("type");
         //清空费用表
@@ -55,7 +56,13 @@ public class OrderFeeCalculatePlan1 extends DataFunction {
         RowsMap itemRowsMap = queryDataFunction(controller, sa_orderid, this.getClass().getSimpleName()).toRowsMap("sys_datafunctionid");
         //查询订单商品和方案
 
-        Rows dfRows = dbConnect.runSqlQuery("select sys_datafunctionid from sys_datafunction WHERE classname='OrderFeeCalculatePlan1' and status='启用' ");
+//        Rows dfRows = dbConnect.runSqlQuery("select sys_datafunctionid from sys_datafunction WHERE classname='OrderFeeCalculatePlan1' and status='启用' ");
+        SQLFactory sqlFactory = new SQLFactory(this, "查询订单方案");
+        sqlFactory.addParameter("siteid", controller.siteid);
+        sqlFactory.addParameter("sa_orderid", sa_orderid);
+        System.err.println(sqlFactory.getSQL());
+        Rows dfRows = dbConnect.runSqlQuery(sqlFactory);
+
         for (Row dfRow : dfRows) {
             String sys_datafunctionid = dfRow.getString("sys_datafunctionid");
             Rows itemRows = itemRowsMap.getOrDefault(sys_datafunctionid, new Rows());
@@ -78,7 +85,8 @@ public class OrderFeeCalculatePlan1 extends DataFunction {
 
 
             if (!ordertype.contains(type)) {
-                return super.action();
+                System.err.println("end2......");
+                continue;
             }
 
             BigDecimal bdUnitfee = unitfee;
@@ -136,6 +144,7 @@ public class OrderFeeCalculatePlan1 extends DataFunction {
                         }
                     }
                 }
+                System.err.println(sqlList);
                 dbConnect.runSqlUpdate(sqlList);
                 //调整最后一行数据
                 adjustLastData(itemRows, totalprice);
@@ -165,13 +174,14 @@ public class OrderFeeCalculatePlan1 extends DataFunction {
                     }
                     sqlList.add(getInsertSQL(row, totalprice).getSQL());
                 }
+                System.err.println(sqlList);
                 dbConnect.runSqlUpdate(sqlList);
             }
 
 
         }
 
-
+        System.err.println("end......");
         return super.action();
     }
 

+ 6 - 0
src/custom/function/SQL/查询订单方案.sql

@@ -0,0 +1,6 @@
+SELECT DISTINCT t3.sys_datafunctionid
+from sa_orderitems t1
+         INNER JOIN sys_datafunction_bind t2 ON t2.ownerid = t1.itemid and t2.ownertable = 'plm_item'
+         INNER JOIN sys_datafunction t3 ON t3.sys_datafunctionid = t2.sys_datafunctionid
+WHERE t1.sa_orderid = $sa_orderid$
+  and t1.siteid = $siteid$ and  t3.status='启用'

+ 8 - 2
src/custom/restcontroller/webmanage/sale/order/OrderItemsHelper.java

@@ -299,8 +299,14 @@ public class OrderItemsHelper extends BaseClass {
         sqlFactory.addParameter("siteid", controller.siteid);
         sqlFactory.addParameter("sa_orderid", sa_orderid);
         Rows rows = dbConnect.runSqlQuery(sqlFactory);
-        for (Row row : rows) {
-            DataFunction df = DataFunction.get(controller, row.getString("functionname"));
+        if(rows.isEmpty()){
+            //清空费用表
+            DeleteSQL deleteSQL = SQLFactory.createDeleteSQL(controller, "sa_order_cost");
+            deleteSQL.setWhere("sa_orderid", sa_orderid);
+            deleteSQL.delete();
+        }
+        if(rows.isNotEmpty()){
+            DataFunction df = DataFunction.get(controller, rows.get(0).getString("functionname"));
             df.addParameter("sa_orderid", sa_orderid);
             df.action();
         }