1
0

first commit

This commit is contained in:
2020-08-06 15:36:28 +08:00
commit fe5c11976c
12348 changed files with 1411979 additions and 0 deletions

2
packages/bonus/README.md Normal file
View File

@@ -0,0 +1,2 @@
# Bonus 奖金结算系统

View File

@@ -0,0 +1,28 @@
{
"name": "rulong/bonus",
"description": "",
"license": "MIT",
"authors": [
{
"name": "C.Jason",
"email": "chenjxlg@163.com"
}
],
"require": {
"php": ">=7.1.3",
"rulong/user-account": "^1.0",
"laravel/framework": "*"
},
"autoload": {
"psr-0": {
"RuLong\\Bonus": "src/"
}
},
"extra": {
"laravel": {
"providers": [
"RuLong\\Bonus\\ServiceProvider"
]
}
}
}

View File

@@ -0,0 +1,13 @@
<?php
return [
'user_model' => \App\User::class,
'Settlement' => [
'Direct' => [
'integral' => 100,
'layer' => 9,
'point' => 5,
],
],
'full_point' => 10,
];

View File

@@ -0,0 +1,20 @@
<?php
namespace RuLong\Bonus;
use RuLong\Bonus\Contracts\Settlement;
class Bonus
{
public $settlement;
public function __construct(Settlement $settlement)
{
$this->settlement = $settlement;
}
public function __destruct()
{
$this->settlement->fire();
}
}

View File

@@ -0,0 +1,15 @@
<?php
namespace RuLong\Bonus\Contracts;
interface Settlement
{
/**
* 子规则的实际计算过程
* @Author:<C.Jason>
* @Date:2018-10-31T14:22:48+0800
*/
function fire();
}

View File

@@ -0,0 +1,29 @@
<?php
namespace RuLong\Bonus\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class Bonus extends Model
{
use SoftDeletes;
protected $guarded = [];
protected $dates = [
'deleted_at',
];
protected $casts = [
'performs' => 'array',
'configs' => 'array',
];
public function logs()
{
return $this->hasMany(BonusLog::class);
}
}

View File

@@ -0,0 +1,21 @@
<?php
namespace RuLong\Bonus\Models;
use Illuminate\Database\Eloquent\Model;
class BonusLog extends Model
{
protected $guarded = [];
public function bouns()
{
return $this->belongsTo(Bonus::class);
}
public function user()
{
return $this->belongsTo(config('rulong_bonus.user_model'));
}
}

View File

@@ -0,0 +1,34 @@
<?php
namespace RuLong\Bonus;
use Illuminate\Support\ServiceProvider as LaravelServiceProvider;
class ServiceProvider extends LaravelServiceProvider
{
/**
* 部署时加载
* @Author:<C.Jason>
* @Date:2018-06-22T16:01:20+0800
* @return [type] [description]
*/
public function boot()
{
if ($this->app->runningInConsole()) {
$this->publishes([__DIR__ . '/../config/rulong_bonus.php' => config_path('rulong_bonus.php')]);
$this->loadMigrationsFrom(__DIR__ . '/../database/migrations/');
}
}
/**
* 注册服务提供者
* @Author:<C.Jason>
* @Date:2018-06-22T16:01:12+0800
* @return [type] [description]
*/
public function register()
{
$this->mergeConfigFrom(__DIR__ . '/../config/rulong_bonus.php', 'rulong_bonus');
}
}

View File

@@ -0,0 +1,20 @@
<?php
namespace RuLong\Bonus\Traits;
use RuLong\UserRelation\Models\UserRelation;
trait BloodLine
{
public function getUpBloodLine($user, $layer)
{
$lineArray = explode(',', $this->strLine);
return UserRelation::whereIn('user_id', $lineArray)->orderBy('layer', 'desc')->limit($layer)->get();
}
public function getDownBloodLine($user, $layer)
{
#Todo...
return UserRelation::where('bloodline', 'like', "%," . $user->id . ",%")->whereBetween('layer', [$user->relation->layer, $user->relation->layer + $layer])->orderBy('layer', 'asc')->get();
}
}

View File

@@ -0,0 +1,14 @@
<?php
namespace RuLong\Bonus\Traits;
use RuLong\Bonus\Bonus;
trait Settlementable
{
public static function settlement()
{
return new Bonus(new static(...func_get_args()));
}
}

View File

@@ -0,0 +1,8 @@
<?php
namespace RuLong\Bonus\Traits;
trait UserHasBonus
{
}