Class: Vendors::DianpingPackage

Inherits:
ApplicationRecord show all
Defined in:
app/models/vendors/dianping_package.rb

Overview

Schema Information

Table name: vendors_dianping_packages

id                    :bigint           not null, primary key
package_type          :string(191)      not null
timeslots             :json
created_at            :datetime         not null
updated_at            :datetime         not null
package_id            :string(191)      not null
restaurant_id         :integer          not null
restaurant_package_id :integer

Indexes

index_dianping_unique_vendors_package                           (package_id,package_type,restaurant_package_id,restaurant_id) UNIQUE
index_vendors_dianping_packages_on_package_id_and_package_type  (package_id,package_type)
index_vendors_dianping_packages_on_restaurant_id                (restaurant_id)
index_vendors_dianping_packages_on_restaurant_package_id        (restaurant_package_id)

Foreign Keys

fk_rails_...  (restaurant_id => restaurants.id)
fk_rails_...  (restaurant_package_id => hh_package_restaurant_packages.id)

The Vendors::DianpingPackage model manages the relationship between HungryHub packages and Dianping's external reservation system. It stores available timeslots that customers can book through the Dianping platform. we set Dianping package id as #restaurant_package_id-#timeslot, for example 86577-1830 we do not save Dianping Package id in this model, its just used to upload packages in dianping and ddecoded in reservaiton api call


Fields:

  • package_id/package_type: Polymorphic reference to the package (e.g., HhPackage::Package::Ayce, etc.)

  • restaurant_id: The restaurant offering this package.

  • restaurant_package_id: Link to the specific restaurant package.

  • timeslots: JSON array of available booking times in “HH:MM” format (e.g., [“10:00”, “18:30”]).

Usage: This model is used in the admin interface to configure which packages are available on Dianping and at what times they can be booked.

Important Implementation Details:

  • The combination of package_id, package_type, restaurant_package_id, and restaurant_id must be unique, enforced by a unique index.

  • The timeslots field should contain valid time strings in “HH:MM” format.

  • The package association is polymorphic, allowing linkage to different package types.


Method Summary

Methods inherited from ApplicationRecord

sync_carrierwave_url