|
|
@@ -15,13 +15,22 @@ public class OrderAutoCheck extends ServiceController {
|
|
|
@Override
|
|
|
public void serviceRun() throws Exception {
|
|
|
|
|
|
+// Rows orderRows = dbConnect.runSqlQuery("select t1.sa_orderid,t1.sa_accountclassid,t1.sys_enterpriseid,t1.sonum,sum(t2.amount)as amount from sa_order t1\n" +
|
|
|
+// "inner join sa_orderitems t2 on t1.sa_orderid=t2.sa_orderid \n" +
|
|
|
+// "inner join sa_agents t3 on t1.sys_enterpriseid=t3.sys_enterpriseid and t3.submitautocheck=1 \n" +
|
|
|
+// "where t1.status='提交' and (t1.type='标准订单')\n" +
|
|
|
+// " and exists(select * from sa_cashbill t5 where ((t5.type=1 and t5.amount>0) or (t5.type=0 and t5.amount<0)) and t5.status='审核' and t5.sys_enterpriseid=t1.sys_enterpriseid and t5.billdate>=date(now()))\n" +
|
|
|
+// "group by t1.sa_orderid,t1.sa_accountclassid,t1.sys_enterpriseid,t1.sonum having sum(t2.amount)>0 order by t1.sys_enterpriseid,sum(t2.amount)");
|
|
|
+
|
|
|
Rows orderRows = dbConnect.runSqlQuery("select t1.sa_orderid,t1.sa_accountclassid,t1.sys_enterpriseid,t1.sonum,sum(t2.amount)as amount from sa_order t1\n" +
|
|
|
- "inner join sa_orderitems t2 on t1.sa_orderid=t2.sa_orderid \n" +
|
|
|
+ "inner join sa_orderitems t2 on t1.sa_orderid=t2.sa_orderid\n" +
|
|
|
"inner join sa_agents t3 on t1.sys_enterpriseid=t3.sys_enterpriseid and t3.submitautocheck=1 \n" +
|
|
|
- "where t1.status='提交' and (t1.type='标准订单')\n" +
|
|
|
- " and exists(select * from sa_cashbill t5 where ((t5.type=1 and t5.amount>0) or (t5.type=0 and t5.amount<0)) and t5.status='审核' and t5.sys_enterpriseid=t1.sys_enterpriseid and t5.billdate>=date(now()))\n" +
|
|
|
- "group by t1.sa_orderid,t1.sa_accountclassid,t1.sys_enterpriseid,t1.sonum having sum(t2.amount)>0 order by t1.sys_enterpriseid,sum(t2.amount)");
|
|
|
- logger.info("监测到有{}个订单待审核", orderRows.size());
|
|
|
+ "where t1.status='提交' and (t1.type='标准订单') \n" +
|
|
|
+ "group by t1.sa_orderid,t1.sa_accountclassid,t1.sys_enterpriseid,t1.sonum having sum(t2.amount)>0\n" +
|
|
|
+ " and exists(select * from sa_accountbalance t4 where t4.sys_enterpriseid=t1.sys_enterpriseid and t4.sa_accountclassid=t1.sa_accountclassid\n" +
|
|
|
+ " and ifnull(t4.balance,0)+ifnull(t4.creditquota,0)+ifnull(t4.discountamount,0)-ifnull(t4.freezamount,0)>= sum(t2.amount))\n" +
|
|
|
+ " order by t1.sys_enterpriseid,sum(t2.amount) ");
|
|
|
+ logger.info("监测到有{}个金额小于等于账户可用余额的待审核订单", orderRows.size());
|
|
|
|
|
|
Controller md = getSysController("MD");
|
|
|
|