Commit bf50cf74 by pye52

1、增加离线订单分批上传机制(避免一次性上传大量订单被服务拒绝)

2、增加数据库版本从1升级到2的迁移机制
parent d4b74d34
package com.bgycc.smartcanteen.data;
import androidx.annotation.NonNull;
import androidx.room.migration.Migration;
import androidx.sqlite.db.SupportSQLiteDatabase;
import com.bgycc.smartcanteen.entity.PayData;
public class _1To_2Migration extends Migration {
public _1To_2Migration() {
super(1, 2);
}
@Override
public void migrate(@NonNull SupportSQLiteDatabase database) {
database.execSQL("ALTER TABLE " + PayData.TABLE_NAME +
" ADD COLUMN uploadTime INTEGER NOT NULL DEFAULT 0");
}
}
...@@ -143,9 +143,11 @@ public class PayOfflineViewModel extends ViewModel { ...@@ -143,9 +143,11 @@ public class PayOfflineViewModel extends ViewModel {
} }
private class RequestRunnable implements Runnable { private class RequestRunnable implements Runnable {
private static final int PAY_OFFLINE_PER_LIMIT = 10;
@Override @Override
public void run() { public void run() {
List<PayData> payData = payDataRepository.queryPayOfflineData(); long currentTime = System.currentTimeMillis();
List<PayData> payData = payDataRepository.queryPayOfflineData(currentTime, PAY_OFFLINE_PER_LIMIT);
if (payData == null || payData.isEmpty()) { if (payData == null || payData.isEmpty()) {
cancelTimeout(); cancelTimeout();
payRequest = null; payRequest = null;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment