|
|
@@ -0,0 +1,43 @@
|
|
|
+package service;
|
|
|
+
|
|
|
+import com.alibaba.fastjson2.JSONObject;
|
|
|
+import common.Controller;
|
|
|
+import common.ServiceController;
|
|
|
+import common.data.Row;
|
|
|
+import common.data.Rows;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+
|
|
|
+public class OrderAutoCheck extends ServiceController {
|
|
|
+ @Override
|
|
|
+ public void serviceRun() throws Exception {
|
|
|
+
|
|
|
+ Rows orderRows = dbConnect.runSqlQuery("select t1.sa_orderid,t1.sonum,t1.sys_enterpriseid,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='提交'\n" + "group by t1.sa_orderid,t1.sys_enterpriseid,t1.sonum having sum(t2.amount)>0 order by t1.sys_enterpriseid,sum(t2.amount)");
|
|
|
+ logger.info("监测到有{}个订单待审核", orderRows.size());
|
|
|
+
|
|
|
+ Controller md = getSysController("MD");
|
|
|
+
|
|
|
+
|
|
|
+ ArrayList<Long> errenterpriseid = new ArrayList<>();
|
|
|
+ for (Row orderRow : orderRows) {
|
|
|
+ long enterpriseid = orderRow.getLong("sys_enterpriseid");
|
|
|
+ if (!errenterpriseid.contains(enterpriseid)) {
|
|
|
+ JSONObject content = new JSONObject();
|
|
|
+ content.put("sa_orderid", orderRow.getLong("sa_orderid"));
|
|
|
+ content.put("reviewtype", "");
|
|
|
+ JSONObject resultObject = (JSONObject) md.callApi(20221108153502L, 1, content);
|
|
|
+ if (resultObject.getIntValue("status") == 0) {
|
|
|
+ logger.info("订单{}审核失败;{}", orderRow.getString("sonum"), resultObject.getString("msg"));
|
|
|
+ errenterpriseid.add(enterpriseid);
|
|
|
+ } else {
|
|
|
+ logger.info("订单{}审核成功", orderRow.getString("sonum"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ServiceParam paramSet() {
|
|
|
+ return new ServiceParam("订单自动审核", 10, RunType.minute);
|
|
|
+ }
|
|
|
+}
|