Shares of JD.com (JD 0.36%) surged this week after the Chinese e-commerce giant's second-quarter numbers crushed analyst expectations. Its revenue rose 23% annually to 150.3 billion RMB ($21.9 billion), topping estimates by nearly $1 billion and marking its strongest growth in three quarters.

JD's adjusted net income rose more than sevenfold to 3.56 billion RMB ($518.4 million), or 2.30 RMB ($0.33) per ADS, which also beat expectations by 25 cents. JD expects its revenue to rise 20%-24% annually in the third quarter, but didn't provide any bottom-line guidance.

JD's big beat indicates that many fears about the company -- including competition from Alibaba (BABA -1.14%) and Pinduoduo, the slowdown in the Chinese economy, and the trade war -- were overblown. As a result, shares of JD, which remain down about 30% over the past two years, could still have room to run.

JD.com's autonomous delivery robot on a street.

A JD.com autonomous delivery robot. Image source: JD.com.

Accelerating sales growth

The number of annual active customers (those who made a purchase over the past 12 months) rose 2.4% annually to 321.3 million during the second quarter. That marked a slowdown from previous quarters, but accelerating revenue growth indicated that customers are spending more money.

Metric

Q2 2018 YOY Growth

Q3 2018 YOY Growth

Q4 2018 YOY Growth

Q1 2019 YOY Growth

Q2 2019 YOY Growth

Annual active customers

21.5%

14.6%

4.4%

2.9%

2.4%

Revenue*

31.2%

25.1%

22.4%

20.9%

22.9%

YOY = year-over-year.. *In RMB. Source: JD.com.

During the conference call with analysts, CFO Sidney Huang noted double-digit sales growth across "all major categories of electronics and home appliances," along with 34% growth across general merchandise categories.

That rising demand for big-ticket items was encouraging. It was a sore spot in JD's recent quarters, and often cited by the bears (those pessimistic about a stock) as evidence of softer consumer spending trends in China.

Expanding margins

JD's total gross margin expanded 120 basis points annually to 14.7% thanks to improvements at both JD Retail (its core marketplace) and JD Logistics (its fulfillment and logistics network).

JD Retail's gross margin rose 76 basis points annually, marking its 21st straight quarter with a rise, thanks to the platform's increasing scale and certain tax reform benefits. JD Logistics also expanded its gross margin to the breakeven level for the first time ever "after years of efforts," according to CEO Richard Liu.

That accomplishment counters Alibaba co-founder Jack Ma's infamous claim several years ago that JD's capital-intensive logistics business would end in "tragedy." Unlike Alibaba, which avoids taking on inventory and outsources its logistics to third-party providers, JD takes ownership of the products sold on its platform and delivers them with its own services. JD's approach is more costly, but weeds out knockoff and low-quality products and gives it tighter control over its entire marketplaces.

JD.com CEO Richard Liu delivers a package.

JD.com CEO Richard Liu. Image source: JD.com.

JD's adjusted operating margin improved 200 basis points annually to 2.1%, while its adjusted EBITDA margin expanded 210 basis points to 2.9%. As JD upgrades its logistics services with new automated solutions -- including autonomous delivery vehicles and drones -- those margins could keep rising. Its adjusted net margin improved 200 basis points to 2.4%.

JD expects to remain consistently profitable for the full year with a net margin of 1.4%-1.7% -- a welcome improvement from its inconsistent profits in previous years.

Its service revenue is soaring

JD's service revenue, which includes ad sales on its platform and JD Logistics' services for third-party companies, surged 42% annually and accounted for 11% of its top line.

Within that total, logistics and other service revenue nearly doubled, highlighting the feverish demand for efficient courier services across China. This indicates that JD's costly investments in its nationwide logistics network are finally paying off, since most rival couriers (including Alibaba-backed Cainiao) lack the scale to compete against JD Logistics and remain profitable.

JD is gradually expanding that ecosystem with new services like JD Cloud, which competes against bigger platforms like Alibaba Cloud and Tencent Cloud, and new AI and big data services for businesses. Those services piggyback off the infrastructure the company already established for its marketplace and logistics platforms, and could grow quickly as JD leverages its strengths in those markets to expand its services.

JD is poised for a comeback

JD still trades at less than one time this year's sales after its recent rally, and its forward P/E of 30 looks cheap relative to forecasts for 94% earnings growth this year and 49% growth next year. It's finally reaping the fruits of its labor in both retail and logistics, and its unified business model makes it a more stable long-term play than Alibaba, which builds its e-commerce empire on a more fragmented network of marketplaces and services.

JD is the second largest e-commerce player in China after Alibaba, but it's the country's biggest direct retailer and enjoys plenty of support from Tencent, Walmart, Alphabet's Google, and other big backers. In other words, JD has been in the penalty box far too long, and its stock could rebound and burn the bears.