feat(shopping): mağazalar, zahmet skoru ve ürünler (marka/paket, dönüşüm, görseller)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
import { model, models, Schema, type InferSchemaType, type Model } from "mongoose";
|
||||
import { MEAL_CARD_PROVIDERS } from "@/shared/accounts";
|
||||
import { STORE_KINDS } from "@/shared/stores";
|
||||
|
||||
/**
|
||||
* Mağaza (Bölüm 6.11): fiziksel market, online platform veya pazar. Hane bazlı (hane içinde
|
||||
* ortak). Uzaklık metre; teslimat ücretleri kuruş. Zahmet skoru okuma sırasında hesaplanır.
|
||||
*/
|
||||
const storeSchema = new Schema(
|
||||
{
|
||||
householdId: { type: Schema.Types.ObjectId, required: true },
|
||||
name: { type: String, required: true, trim: true, maxlength: 80 },
|
||||
nameKey: { type: String, required: true },
|
||||
kind: { type: String, enum: STORE_KINDS, required: true },
|
||||
branch: { type: String, default: "", maxlength: 80 },
|
||||
/** Eve uzaklık (metre); online mağazada null. */
|
||||
distanceM: { type: Number, default: null, min: 0 },
|
||||
/** Taşıma güçlüğü 1 (kolay) – 5 (çok zor). */
|
||||
carryDifficulty: { type: Number, default: 1, min: 1, max: 5 },
|
||||
/** Online: teslimat ücreti ve ücretsiz teslimat alt limiti (kuruş). */
|
||||
deliveryFeeMinor: { type: Number, default: null, min: 0 },
|
||||
freeDeliveryMinMinor: { type: Number, default: null, min: 0 },
|
||||
mealCardAccepted: { type: Boolean, default: false },
|
||||
mealCardProviders: { type: [{ type: String, enum: MEAL_CARD_PROVIDERS }], default: [] },
|
||||
note: { type: String, default: "", maxlength: 300 },
|
||||
archivedAt: { type: Date, default: null },
|
||||
seedRef: { type: String, default: null },
|
||||
createdBy: { type: Schema.Types.ObjectId, required: true },
|
||||
updatedBy: { type: Schema.Types.ObjectId, required: true },
|
||||
},
|
||||
{ timestamps: true, collection: "stores" },
|
||||
);
|
||||
|
||||
storeSchema.index({ householdId: 1, archivedAt: 1, nameKey: 1 });
|
||||
storeSchema.index(
|
||||
{ householdId: 1, seedRef: 1 },
|
||||
{ unique: true, partialFilterExpression: { seedRef: { $type: "string" } } },
|
||||
);
|
||||
|
||||
export type Store = InferSchemaType<typeof storeSchema>;
|
||||
|
||||
export const StoreModel: Model<Store> =
|
||||
(models.Store as Model<Store> | undefined) ?? model<Store>("Store", storeSchema);
|
||||
Reference in New Issue
Block a user