Cross-Border E-Commerce Profit-Sharing Mall System Source Code Setup: Multi-Language Mall + Payment Integration + Distributor Commission Customization

Disclaimer: This article is for technical education and demonstration only. It is not professional or financial advice. Any real-world deployment must comply with applicable laws and regulations.

I recently helped a client deploy a profit-sharing mall system for cross-border e-commerce. The requirements covered the whole package: platform commission, distributor revenue sharing, and store payment QR codes. The client runs supply chain distribution and used to reconcile accounts manually — their finance team had to work three days of overtime every month-end — so they decided to bite the bullet and adopt this system. The source code is a comprehensive admin backend written in ThinkPHP. The overall structure is fairly clean, but getting it actually running involves plenty of pitfalls. This post documents my customization process in order.

How to Set Up the Environment

The server is a 2C4G lightweight cloud instance running CentOS 7.9, with PHP 7.4 + MySQL 5.7 + Nginx. Don’t use PHP 8 — the source code contains several legacy syntax patterns that cause a blank screen on 8.0. I tried fixing it and it required touching a dozen or so places; not worth it. Use the thinkphp rewrite rules for pseudo-static URLs. The backend entry point defaults to /admin.php, and the first thing to do after installation is rename the entry file and change the backend path — standard practice.

There was a pitfall during database import: one table in the SQL file carried a DEFINER clause, and the import failed with a 1227 permission error. I removed the DEFINER line with sed and re-imported — done in two minutes. Also remember to set the runtime cache directory permissions to 755, otherwise the homepage loads but the backend captcha image won’t display, which is a very confusing error.

How I Modified the Payment Channel

The system natively uses a service-provider split settlement mode, with the platform commission ratio configured in the backend under “Split Settlement Settings,” supporting per-sub-merchant commission ratios. The client wanted to connect their own payment channel, so I modified the driver classes in the pay directory. The original driver was written for the service-provider mode, reading the merchant ID, APIv2 key, and certificate paths from backend configuration. I added a direct-connection mode driver, roughly 200 lines of code, mainly handling signing and callback signature verification.

Callback Signature Verification Pitfalls

Callbacks kept returning failure, with the logs showing “signature verification error.” After much digging, it turned out the local server’s clock was 4 minutes off from the payment platform’s, exceeding the verification window. After installing chrony to sync time on the server, it passed on the first try. Also, callbacks need idempotency handling — I used a Redis lock keyed on order number + status so duplicate notifications return success immediately; otherwise the voice announcement would play twice.

Customizing Distributor Commission and Payment QR Codes

This was the client’s core requirement. The system supports self-generated payment QR codes for distributor stores, with each code bound to a store ID. After a user scans and pays, funds are automatically split by ratio: platform commission, distributor share, and store retention. I added two customizations:

First, tiered commission ratio configuration. The original version used fixed ratios, so I added a ratio table with different tiers based on monthly transaction volume ranges. Finance staff can adjust it in the backend without asking me to change code.

Second, payment voice announcements. The system already supports announcement devices via the cloud speaker protocol. I integrated the client’s device model, and during testing found announcement latency up to 8 seconds. I changed the announcement push to asynchronous queue processing (the original was synchronous), bringing latency down to under 1 second.

Tip: always keep an operation log for split ratio changes. The original version had none, so I added an op_log table recording who changed the ratio and the before/after values — this cuts reconciliation disputes in half.

Multi-Language and Points Mall Done Along the Way

The client has overseas warehouse operations, so the storefront needed an English version. The backend is monolingual, so I implemented language pack switching at the frontend template layer with two JSON files (en/zh), added a name_en field to the product table, and made the backend product editor dual-column. It took a day and a half, mostly translating the product category vocabulary.

The points mall is built into the original version — purchases earn points, and the redemption ratio is adjustable in the backend. The client wanted points to expire on a rolling one-year basis, so I added an expire_at field to the points ledger table and wrote a cleanup task that runs at 2 a.m. nightly, hooked into crontab.

FAQ

Q: Is PHP 7.4 mandatory?
A: 7.2 through 7.4 all work; 7.4 is recommended. 8.x shows a blank screen — don’t bother.

Q: Can split ratios be set individually per distributor?
A: Yes. Each merchant is configured independently in the backend’s sub-merchant management, and the tiered ratios I added also take effect at the merchant level.

Q: Is there a limit on how many payment QR codes can be generated?
A: The original version has no limit, but I’d suggest keeping it under 5,000 per platform. Queries are fine once the code table is indexed, but beyond that the backend list gets sluggish.

Q: How do I integrate a voice announcement device?
A: Use the cloud speaker HTTP push endpoint and forward the payment-success event to it. Make sure to use an asynchronous queue — synchronous pushes will slow down the payment callback response.

The whole deployment plus customization took me 6 working days in total: half a day for the environment, two days for the payment channel, and a bit over a day each for commission and multi-language. The system has a solid foundation and suits compliant businesses like distributor distribution and supply chain profit sharing. One final reminder: comply with all applicable laws and regulations when deploying, never use it for any illegal purposes, and complete all required payment-related licensing before going live.

Disclaimer: This article is for technical education and demonstration only. It is not professional or financial advice. Any real-world deployment must comply with applicable laws and regulations.

#Cross-Border E-Commerce #System Setup #Payment Integration #Secondary Development #Source Code Deployment