|
|
@@ -1866,4 +1866,58 @@ public class OrderItems extends Controller {
|
|
|
return sqlList;
|
|
|
}
|
|
|
|
|
|
+ @API(title = "刷订单保修状态", apiversion = R.ID2026040214285502.v1.class)
|
|
|
+ public String updatebillingstatus() throws YosException {
|
|
|
+ System.err.println(getDateTime_Str() + ":准备刷订单保修状态...");
|
|
|
+
|
|
|
+ String sql = "SELECT if(billdate BETWEEN begdate and enddate,if(price>0,'保内收费','保内免费'),'保外收费' ) billingstatus,sa_orderitemsid ,verifiedqty,tobeoffqty,canoffqty from ( " +
|
|
|
+ "SELECT t1.sa_orderitemsid,t1.price,t2.billdate, IF(isvoid=1,voiddate,enddate) enddate,begdate,verifiedqty,tobeoffqty,canoffqty from sa_orderitems t1 " +
|
|
|
+ "INNER JOIN sa_order t2 ON t2.sa_orderid=t1.sa_orderid " +
|
|
|
+ "LEFT JOIN sa_warrantycard t3 ON t3.cardno=t1.cardno " +
|
|
|
+ "WHERE t2.type='配件订单' " +
|
|
|
+ "and t1.billingstatus is null " +
|
|
|
+ "and t2.deleted=0 " +
|
|
|
+ "and t2.billdate<='2025-12-05' " +
|
|
|
+ "ORDER BY t2.billdate " +
|
|
|
+ ") a ";
|
|
|
+
|
|
|
+ // 用于暂存 SQL 的列表
|
|
|
+ ArrayList<String> sqlList = new ArrayList<>();
|
|
|
+ // 设定批次大小
|
|
|
+ int batchSize = 5000;
|
|
|
+
|
|
|
+ Rows rows = dbConnect.runSqlQuery(sql);
|
|
|
+ int count = 0; // 计数器
|
|
|
+
|
|
|
+ for (Row row : rows) {
|
|
|
+ UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, "sa_orderitems");
|
|
|
+ updateSQL.setSiteid(siteid);
|
|
|
+ updateSQL.setUniqueid(row.getLong("sa_orderitemsid"));
|
|
|
+ updateSQL.setValue("billingstatus", row.getString("billingstatus"));
|
|
|
+ updateSQL.setValue("canoffqty", 0);
|
|
|
+
|
|
|
+ // 将生成的 SQL 加入列表
|
|
|
+ sqlList.add(updateSQL.getSQL());
|
|
|
+ count++;
|
|
|
+
|
|
|
+ // 当达到批次大小时,执行更新并清空列表
|
|
|
+ if (count % batchSize == 0) {
|
|
|
+ System.err.println(getDateTime_Str() + ":正在执行第 " + count + " 条数据的批量更新...");
|
|
|
+ dbConnect.runSqlUpdate(sqlList);
|
|
|
+ sqlList.clear(); // 清空列表以释放内存
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 【重要】循环结束后,处理剩余不足 5000 条的数据
|
|
|
+ if (!sqlList.isEmpty()) {
|
|
|
+ System.err.println(getDateTime_Str() + ":正在执行最后剩余 " + sqlList.size() + " 条数据的批量更新...");
|
|
|
+ dbConnect.runSqlUpdate(sqlList);
|
|
|
+ sqlList.clear();
|
|
|
+ }
|
|
|
+
|
|
|
+ System.err.println(getDateTime_Str() + ":结束刷订单保修状态...");
|
|
|
+ return getSucReturnObject().toString();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|