Pharma wholesale ordering platform with ERP integration

A B2B ordering platform for pharmaceutical wholesale: a buyer mini-program, an operator console and a Spring Boot API. Scheduled jobs pull product and stock from the distributor's ERP and push orders and customers back, with retries.

Direct answer. We built self-service ordering for a pharmaceutical wholesaler while the distributor’s ERP stayed the system of record: scheduled jobs pull catalogue and stock, push orders and customers back with retry, and poll document status until goods ship and invoices are issued.

Summary

Pharmacies and clinics order through a mini-program. Operators manage products, buyer qualifications, orders and after-sales in a web console. Products, stock and invoices still come from the ERP, and the platform only sends paid, approved orders and their customers.

Integration flow: the buyer mini-program and operator console use the platform API; scheduled jobs pull products from the ERP every 30 minutes and stock every minute, push orders and customers every minute with retry, and poll document status every 5 minutes, turning posted outbound documents into shipped orders and fetching invoices.

Problem

Wholesale buyers needed self-service ordering, but stock, accounting and invoicing had to stay in the ERP. The two systems had to stay consistent through an interface specification published by the ERP side.

Constraints

  • The ERP is the system of record for products, stock, document status and invoices.
  • Buyer qualifications have to be checked before purchase, including document recognition for uploaded licences.
  • Development and tests must run without live payment, logistics, notification or ERP access.

Architecture

PartImplementation
BackendJava 17, Spring Boot 3.3, MySQL 8, Redis, S3-compatible object storage, Flyway migrations
ClientsMessaging-platform mini-program for buyers; Vue 3 operator console
ERP adapterSwitchable between an in-memory mock, which moves orders through to “posted” and produces invoices, and the HTTP implementation
SchedulesCatalogue pull every 30 minutes; stock pull every minute; order and customer push with retry every minute; document-status poll every 5 minutes
OperationsConsole integration page with sync status and logs; sync, push and polling can be triggered by hand

Key decisions

  1. Pull and poll, no shared database. The platform reaches the ERP only through its published interface, so a schema change on either side does not break the other.
  2. Mock-first adapters. Payment, logistics, notification and ERP each have a mock, which lets the whole order lifecycle, invoicing included, run locally without partner credentials.
  3. Secrets stay out of the repository. CI runs backend verification, console lint, typecheck, tests and build, plus a secret scan, and only example environment files are committed.

Evidence

  • 45 backend test classes and 56 migration files.
  • Production deployment documents cover release, rollback, secret rotation, backup and restore.

Limits

Order volume, number of buyers, go-live date and commercial terms are not published.

Frequently asked questions

How does stock stay in sync with the ERP?

Products are pulled every 30 minutes and stock every minute. Orders and customers are pushed with retry. Document status is polled every 5 minutes.

Can it be developed without access to the real ERP?

A mock ERP adapter simulates the document lifecycle, including invoicing.

What happens when an ERP push fails?

The record stays queued and is retried on the next one-minute run. Operators can see sync logs and trigger a retry from the console.