add: admin shop shipment

This commit is contained in:
morteza-mortezai
2025-10-26 16:50:17 +03:30
parent 1e38c353f2
commit e469a2eadd
4 changed files with 65 additions and 3 deletions
+23
View File
@@ -327,6 +327,29 @@ class SellerService {
};
}
async updateShopShipperForAdmin(sellerId: string, updateDto: UpdateShopShipmentDTO, type: "activate" | "deactivate") {
const { shipmentId } = updateDto;
const shop = await this.shopRepo.model.findOne({ owner: sellerId, ownerRef: OwnerRef.ADMIN });
if (!shop) throw new BadRequestError(ShopMessage.ShopNotFound);
if (type === "activate") {
if (shop.shipmentMethod.includes(shipmentId)) throw new BadRequestError(SetShipmentMessage.ShipmentMethodAlreadyActive);
shop.shipmentMethod.push(shipmentId);
} else {
if (!shop.shipmentMethod.includes(shipmentId)) throw new BadRequestError(SetShipmentMessage.ShipmentMethodNotActive);
shop.shipmentMethod = shop.shipmentMethod.filter((methodId) => methodId !== shipmentId);
}
await shop.save();
return {
message: CommonMessage.Updated,
};
}
async changeShopChatStatus(sellerId: string) {
const shop = await this.shopRepo.model.findOne({ owner: sellerId, ownerRef: OwnerRef.SELLER });
if (!shop) throw new BadRequestError(ShopMessage.ShopNotFound);