定制 nepster-web/php-mlm-matrix 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

nepster-web/php-mlm-matrix

Composer 安装命令:

composer require nepster-web/php-mlm-matrix

包简介

Library for working with mlm matrices

README 文档

README

Latest Version Software License Total Downloads

Library for working with MLM matrices.

Did you find an error?

If you found an error in the code or grammatical mistake or any inaccuracy, please create new issues.

What is the MLM matrix?

Among the many MLM compensation plans available today, the Matrix plan is among the most popularly recommended owing to its uncomplicated structure. As it is quite simple in understanding it is considered very useful and resourceful and can be easily integrated into the MLM business.

To understand the Matrix plan, it makes sense to first understand its structure. The matrix
has fixed numbers of rows and columns, organizing the numbers in a particular width and depth. Typically, most MLM Matrix plans follow two types of structures; 2x2 or the 3x3, but there are exceptions based on company requirements. All the members in a Matrix Plan are positioned serially from top to bottom or left to right.

demo

After the matrix is filled, user at level 1 receives a reward and the matrix itself is divided into several matrices (depends on matrix pow, for example the cubic matrix will be divided into 3 new matrices). After that, new matrices wait for filling and cycle is repeated.

Install

The preferred way to install this extension is through composer.

Either run

$ php composer.phar require --prefer-dist nepster-web/php-mlm-matrix "*"

or add

"nepster-web/php-mlm-matrix": "*"

to the require section of your composer.json file.

Structure

  • demo - Library demo
  • doc - Documentation files for GitHub
  • shema - Sample database table schema (MySQL)
  • src - Main library code
  • tests - Unit tests

Usage

Creating a new matrix object:

use Nepster\Matrix\Matrix;

$matrix = new Matrix(3, 2);

Getting information about the matrix:

$matrix->getDepth();
$matrix->getPow();

Get matrix array:

$matrix->toArray();

Managing users in the matrix:

use Nepster\Matrix\Coord;
use Nepster\Matrix\Matrix;

$matrix = new Matrix(3, 2);

$matrix->addTenant(null, function() {
    // return your user data
})

$matrix->addTenant(new Coord(1, 1), function() {
    // return your user data
})

$matrix->hasTenant(new Coord(0, 0));
$matrix->hasTenant(new Coord(1, 1));

$matrix->removeTenant(new Coord(1, 1));

Check the correctness of coordinates:

$matrix->isValidCoord(new Coord(0, 0));

Check if there are free positions in the matrix:

$matrix->isFilled();

For more examples, see the demo file.

How can I use database for matrices?

Based on the different specifics of mlm projects and web development tools, this library implements only the algorithm of operation of mlm matrices without storage support.

However, if you works with the database you can easily implement keeping and restore of matrix objects. You can study the example in the file MySQL schema.

For example, create a new service that allows you to write and/or restore the matrix object from the database:

class MatrixService {

    public function findById(int $id): Matrix
    {
        // You need make a query to the `matrix` table that find the required record
        // Use join or another query to retrieve user data from the `matrix_users` table
        // Initialize new Matrix object
        // Using `addTenant` method that add users to Matrix object (based on data from `matrix_users` table)
        // Return the proper Matrix object
    }

    public function save(Matrix $matrix): void
    {
        // Get the matrix array using the `$matrix->toArray()` method
        // Create a valid request to save data to the database
        // - Most likely in a relational database you will have 2 tables (matrices and matrix_users)
        // - Don`t forget to check a new matrix is being created or edited an already existing matrix
        
        // Note1: Write down users with depth and number for further recovery
        // Note2: Don`t write coordinates with empty positions to the database.
    }

}

Testing

$ phpunit

or

$ vendor/bin/phpunit

License

This library is licensed under the MIT License - see the LICENSE file for details.

nepster-web/php-mlm-matrix 适用场景与选型建议

nepster-web/php-mlm-matrix 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 792 次下载、GitHub Stars 达 58, 最近一次更新时间为 2015 年 02 月 06 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「mlm matrix」 「network marketing」 「mlm marketing」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 nepster-web/php-mlm-matrix 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 nepster-web/php-mlm-matrix 我们能提供哪些服务?
定制开发 / 二次开发

基于 nepster-web/php-mlm-matrix 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 792
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 59
  • 点击次数: 24
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 58
  • Watchers: 13
  • Forks: 48
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-02-06