20260726225220

This commit is contained in:
oneao committed 2026-07-26 22:52:21 +08:00
1 parent e3c7c6f8da
commit a8478d60ed
170 files changed
+6786 -1678

No files matched your search

+2 -16
View File
@@ -7,7 +7,7 @@ import {
FinanceCategoryStatus,
FinanceType,
} from "@/types/finance";
import { shouldRun, getMissedDates } from "@/helpers/financeAuto";
import { shouldRun, getMissedDates, buildAutoBillInserts } from "@/helpers/financeAuto";
import AsyncStorage from "@react-native-async-storage/async-storage";
const AUTO_BILL_IDS_KEY = "finance_auto_bill_ids";
@@ -141,22 +141,8 @@ export const useFinanceStore = create<FinanceState>((set, get) => ({
const missedDates = getMissedDates(rule.repeat_type, rule.repeat_date ?? "", rule.last_run);
if (missedDates.length === 0) continue;
const inserts: any[] = [];
const ids = (await getUniqueIdApi(missedDates.length)).data ?? [];
for (let i = 0; i < missedDates.length; i++) {
if (!ids[i]) continue;
inserts.push({
id: ids[i],
family_id: familyId,
category_id: rule.category_id,
amount: rule.amount,
remark: rule.remark || "",
type: rule.type,
record_time: missedDates[i],
create_by: userId,
update_by: userId,
});
}
const inserts = buildAutoBillInserts(rule, missedDates, ids, userId, familyId);
if (inserts.length > 0) {
await saveDataApi([
+36
View File
@@ -113,6 +113,10 @@ interface MealState {
}) => Promise<number | null>;
confirmPlan: (params: { planId: number; familyId: number; userId: number }) => Promise<boolean>;
completePlan: (params: { planId: number; familyId: number; userId: number }) => Promise<boolean>;
/** 撤回确认:已确认 → 进行中 */
revertPlanToPlanning: (params: { planId: number; familyId: number; userId: number }) => Promise<boolean>;
/** 撤回完成:已完成 → 已确认 */
revertPlanToConfirmed: (params: { planId: number; familyId: number; userId: number }) => Promise<boolean>;
addDishToPlan: (params: {
familyId: number;
planId: number;
@@ -612,6 +616,38 @@ export const useMealStore = create<MealState>((set, get) => ({
});
},
// 撤回确认(已确认 → 进行中)
revertPlanToPlanning: async ({ planId, familyId, userId }) => {
if (!familyId || !planId) return false;
const now = new Date().toISOString();
return get().savePlanChanges({
updates: [
{
id: planId,
status: MealPlanStatus.Planning,
update_time: now,
update_by: userId,
},
],
});
},
// 撤回完成(已完成 → 已确认)
revertPlanToConfirmed: async ({ planId, familyId, userId }) => {
if (!familyId || !planId) return false;
const now = new Date().toISOString();
return get().savePlanChanges({
updates: [
{
id: planId,
status: MealPlanStatus.Confirmed,
update_time: now,
update_by: userId,
},
],
});
},
// 添加菜品到菜单(事件驱动:写入 plan_item + plan_log)
addDishToPlan: async ({ familyId, planId, dishId, dishName, userId, sortNumber }) => {
if (!familyId || !planId) return {};