add: admin shop shipment
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user