Prechádzať zdrojové kódy

订单自动审核增加账户可用金额判断

shenjingwei 4 mesiacov pred
rodič
commit
5b821c618b
1 zmenil súbory, kde vykonal 8 pridanie a 2 odobranie
  1. 8 2
      src/custom/service/OrderAutoCheck.java

+ 8 - 2
src/custom/service/OrderAutoCheck.java

@@ -15,12 +15,12 @@ public class OrderAutoCheck extends ServiceController {
     @Override
     @Override
     public void serviceRun() throws Exception {
     public void serviceRun() throws Exception {
 
 
-        Rows orderRows = dbConnect.runSqlQuery("select t1.sa_orderid,t1.sys_enterpriseid,t1.sonum,sum(t2.amount)as amount from sa_order t1\n" +
+        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" +
                 "inner join sa_agents t3 on t1.sys_enterpriseid=t3.sys_enterpriseid and t3.submitautocheck=1 \n" +
                 "where t1.status='提交' and not exists(select * from sa_orderitems t4 where t1.sa_orderid=t4.sa_orderid and t4.remarks is not null)\n" +
                 "where t1.status='提交' and not exists(select * from sa_orderitems t4 where t1.sa_orderid=t4.sa_orderid and t4.remarks is not null)\n" +
                 "  and exists(select * from sa_cashbill t5 where t5.type=1 and t5.status='审核' and t5.sys_enterpriseid=t1.sys_enterpriseid and t5.billdate>=date(now()))\n" +
                 "  and exists(select * from sa_cashbill t5 where t5.type=1 and t5.status='审核' and t5.sys_enterpriseid=t1.sys_enterpriseid and t5.billdate>=date(now()))\n" +
-                "group by t1.sa_orderid,t1.sys_enterpriseid,t1.sonum having sum(t2.amount)>0 order by t1.sys_enterpriseid,sum(t2.amount)");
+                "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());
         logger.info("监测到有{}个订单待审核", orderRows.size());
 
 
         Controller md = getSysController("MD");
         Controller md = getSysController("MD");
@@ -30,6 +30,12 @@ public class OrderAutoCheck extends ServiceController {
         for (Row orderRow : orderRows) {
         for (Row orderRow : orderRows) {
             long enterpriseid = orderRow.getLong("sys_enterpriseid");
             long enterpriseid = orderRow.getLong("sys_enterpriseid");
             if (!errenterpriseid.contains(enterpriseid)) {
             if (!errenterpriseid.contains(enterpriseid)) {
+                long sa_accountclassid = orderRow.getLong("sa_accountclassid");
+                double amount = orderRow.getDouble("amount");
+                Rows accountbalanceRows = dbConnect.runSqlQuery("select ifnull(balance,0)+ifnull(creditquota,0)+ifnull(discountamount,0)-ifnull(freezamount,0) as canuseamount from sa_accountbalance where sys_enterpriseid=" + enterpriseid + " and sa_accountclassid=" + sa_accountclassid);
+                if (accountbalanceRows.isEmpty() || accountbalanceRows.get(0).getDouble("canuseamount") < amount) {
+                    continue;
+                }
                 JSONObject content = new JSONObject();
                 JSONObject content = new JSONObject();
                 content.put("sa_orderid", orderRow.getLong("sa_orderid"));
                 content.put("sa_orderid", orderRow.getLong("sa_orderid"));
                 content.put("reviewtype", "");
                 content.put("reviewtype", "");