release
parent
cfcc3b1b3c
commit
8ec8067174
|
|
@ -9,6 +9,7 @@ use App\Admin\Forms\Settings\Ios;
|
|||
use App\Admin\Forms\Settings\Kuaidi100;
|
||||
use App\Admin\Forms\Settings\Unipush;
|
||||
use App\Admin\Forms\Settings\Withdraw;
|
||||
use App\Admin\Forms\Settings\Distribution;
|
||||
use App\Admin\Repositories\Setting;
|
||||
use Dcat\Admin\Admin;
|
||||
use Dcat\Admin\Form;
|
||||
|
|
@ -107,72 +108,24 @@ class SettingController extends AdminController
|
|||
->body(function (Row $row) {
|
||||
$type = Request::query('type', 'app');
|
||||
$tab = new Tab();
|
||||
switch ($type) {
|
||||
case 'app':
|
||||
$tab->add('系统配置', new App(), true);
|
||||
$tab->addLink('提现配置', admin_route('settings.index', ['type'=>'withdraw']));
|
||||
$tab->addLink('Ios配置', admin_route('settings.index', ['type'=>'ios']));
|
||||
$tab->addLink('Android配置', admin_route('settings.index', ['type'=>'ios']));
|
||||
$tab->addLink('快递100配置', admin_route('settings.index', ['type'=>'kuaidi100']));
|
||||
$tab->addLink('Uni-push配置', admin_route('settings.index', ['type'=>'unipush']));
|
||||
$tab->addLink('自定义配置', admin_route('settings.index', ['type'=>'custom']));
|
||||
break;
|
||||
case 'withdraw':
|
||||
$tab->addLink('系统配置', admin_route('settings.index', ['type'=>'app']));
|
||||
$tab->add('提现配置', new Withdraw(), true);
|
||||
$tab->addLink('Ios配置', admin_route('settings.index', ['type'=>'ios']));
|
||||
$tab->addLink('Android配置', admin_route('settings.index', ['type'=>'android']));
|
||||
$tab->addLink('快递100配置', admin_route('settings.index', ['type'=>'kuaidi100']));
|
||||
$tab->addLink('Uni-push配置', admin_route('settings.index', ['type'=>'unipush']));
|
||||
$tab->addLink('自定义配置', admin_route('settings.index', ['type'=>'custom']));
|
||||
break;
|
||||
case 'ios':
|
||||
$tab->addLink('系统配置', admin_route('settings.index', ['type'=>'app']));
|
||||
$tab->addLink('提现配置', admin_route('settings.index', ['type'=>'withdraw']));
|
||||
$tab->add('Ios配置', new Ios(), true);
|
||||
$tab->addLink('Android配置', admin_route('settings.index', ['type'=>'android']));
|
||||
$tab->addLink('快递100配置', admin_route('settings.index', ['type'=>'kuaidi100']));
|
||||
$tab->addLink('Uni-push配置', admin_route('settings.index', ['type'=>'unipush']));
|
||||
$tab->addLink('自定义配置', admin_route('settings.index', ['type'=>'custom']));
|
||||
break;
|
||||
case 'android':
|
||||
$tab->addLink('系统配置', admin_route('settings.index', ['type'=>'app']));
|
||||
$tab->addLink('提现配置', admin_route('settings.index', ['type'=>'withdraw']));
|
||||
$tab->addLink('Ios配置', admin_route('settings.index', ['type'=>'ios']));
|
||||
$tab->add('Android配置', new Android(), true);
|
||||
$tab->addLink('快递100配置', admin_route('settings.index', ['type'=>'kuaidi100']));
|
||||
$tab->addLink('Uni-push配置', admin_route('settings.index', ['type'=>'unipush']));
|
||||
$tab->addLink('自定义配置', admin_route('settings.index', ['type'=>'custom']));
|
||||
break;
|
||||
case 'kuaidi100':
|
||||
$tab->addLink('系统配置', admin_route('settings.index', ['type'=>'app']));
|
||||
$tab->addLink('提现配置', admin_route('settings.index', ['type'=>'withdraw']));
|
||||
$tab->addLink('Ios配置', admin_route('settings.index', ['type'=>'ios']));
|
||||
$tab->addLink('Android配置', admin_route('settings.index', ['type'=>'android']));
|
||||
$tab->add('快递100配置', new Kuaidi100(), true);
|
||||
$tab->addLink('Uni-push配置', admin_route('settings.index', ['type'=>'unipush']));
|
||||
$tab->addLink('自定义配置', admin_route('settings.index', ['type'=>'custom']));
|
||||
break;
|
||||
case 'unipush':
|
||||
$tab->addLink('系统配置', admin_route('settings.index', ['type'=>'app']));
|
||||
$tab->addLink('提现配置', admin_route('settings.index', ['type'=>'withdraw']));
|
||||
$tab->addLink('Ios配置', admin_route('settings.index', ['type'=>'ios']));
|
||||
$tab->addLink('Android配置', admin_route('settings.index', ['type'=>'android']));
|
||||
$tab->addLink('快递100配置', admin_route('settings.index', ['type'=>'kuaidi100']));
|
||||
$tab->add('Uni-push配置', new Unipush(), true);
|
||||
$tab->addLink('自定义配置', admin_route('settings.index', ['type'=>'custom']));
|
||||
break;
|
||||
case 'custom':
|
||||
$tab->addLink('系统配置', admin_route('settings.index', ['type'=>'app']));
|
||||
$tab->addLink('提现配置', admin_route('settings.index', ['type'=>'withdraw']));
|
||||
$tab->addLink('Ios配置', admin_route('settings.index', ['type'=>'ios']));
|
||||
$tab->addLink('Android配置', admin_route('settings.index', ['type'=>'android']));
|
||||
$tab->addLink('快递100配置', admin_route('settings.index', ['type'=>'kuaidi100']));
|
||||
$tab->addLink('Uni-push配置', admin_route('settings.index', ['type'=>'unipush']));
|
||||
$tab->add('自定义配置', new Custom(), true);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
$tabs = [
|
||||
'app' => ['name' => '系统配置', 'form' => new App(), 'route' => admin_route('settings.index', ['type'=>'app'])],
|
||||
'withdraw' => ['name' => '提现配置', 'form' => new Withdraw(), 'route' => admin_route('settings.index', ['type'=>'withdraw'])],
|
||||
'ios' => ['name' => 'IOS配置', 'form' => new Ios(), 'route' => admin_route('settings.index', ['type'=>'ios'])],
|
||||
'android' => ['name' => 'Android配置', 'form' => new Android(), 'route' => admin_route('settings.index', ['type'=>'android'])],
|
||||
'kuaidi100' => ['name' => '快递100配置', 'form' => new Kuaidi100(), 'route' => admin_route('settings.index', ['type'=>'kuaidi100'])],
|
||||
'unipush' => ['name' => 'Uni-push配置', 'form' => new Unipush(), 'route' => admin_route('settings.index', ['type'=>'unipush'])],
|
||||
'distribution' => ['name' => '分销配置', 'form' => new Distribution(), 'route' => admin_route('settings.index', ['type'=>'distribution'])],
|
||||
'custom' => ['name' => '自定义配置', 'form' => new Custom(), 'route' => admin_route('settings.index', ['type'=>'custom'])],
|
||||
];
|
||||
if (isset($tabs[$type])) {
|
||||
foreach($tabs as $key => $item) {
|
||||
if ($key === $type) {
|
||||
$tab->add($item['name'], $item['form'], true);
|
||||
} else {
|
||||
$tab->addLink($item['name'], $item['route']);
|
||||
}
|
||||
}
|
||||
}
|
||||
$row->column(12, $tab->withCard());
|
||||
});
|
||||
|
|
|
|||
|
|
@ -0,0 +1,68 @@
|
|||
<?php
|
||||
|
||||
namespace App\Admin\Forms\Settings;
|
||||
|
||||
use App\Models\Setting;
|
||||
use App\Services\{SettingService, DistributeService};
|
||||
use Dcat\Admin\Widgets\Form;
|
||||
|
||||
/**
|
||||
* 分销设置
|
||||
*/
|
||||
class Distribution extends Form
|
||||
{
|
||||
|
||||
/**
|
||||
* Handle the form request.
|
||||
*
|
||||
* @param array $input
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle(array $input)
|
||||
{
|
||||
Setting::where('key', 'distribution')->updateOrCreate([
|
||||
'key' => 'distribution',
|
||||
], ['value' => $input]);
|
||||
|
||||
//清配置缓存
|
||||
app(SettingService::class)->cleanCache('distribution');
|
||||
|
||||
return $this
|
||||
->response()
|
||||
->success('配置更新成功!')
|
||||
->refresh();
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a form here.
|
||||
*/
|
||||
public function form()
|
||||
{
|
||||
$values = Setting::where('key', 'distribution')->value('value');
|
||||
$levels = DistributeService::$levels;
|
||||
$favoite = $levels['favoite'];
|
||||
$agent = $levels['agent'];
|
||||
$this->fieldset('爱好者-返利', function (Form $form) use ($favoite) {
|
||||
foreach($favoite as $item) {
|
||||
$form->number('favoite-profit-' . $item['level'], $item['name'])->min(0)->max(100)->help('例如: 40, 即表示: 40%');
|
||||
}
|
||||
});
|
||||
$this->fieldset('爱好者-升级', function (Form $form) use ($favoite) {
|
||||
foreach($favoite as $item) {
|
||||
$form->number('favoite-level-' . $item['level'], $item['name'])->min(0)->help('例如: 1000');
|
||||
}
|
||||
})->collapsed();
|
||||
$this->fieldset('代理-返利', function (Form $form) use ($agent) {
|
||||
foreach($agent as $item) {
|
||||
$form->number('agent-profit-' . $item['level'], $item['name'])->min(0)->max(100)->help('例如: 40, 即表示: 40%');
|
||||
}
|
||||
})->collapsed();
|
||||
}
|
||||
|
||||
public function default()
|
||||
{
|
||||
$values = Setting::where('key', 'distribution')->value('value');
|
||||
return $values;
|
||||
}
|
||||
}
|
||||
|
|
@ -36,7 +36,9 @@ class ProductSkuFilter extends ModelFilter
|
|||
*/
|
||||
public function keyword($keyword)
|
||||
{
|
||||
$this->whereLike('name', $keyword);
|
||||
$this->where(function ($q) use ($keyword) {
|
||||
$q->whereLike('name', $keyword)->orWhere('subtitle', 'like', '%'.$keyword.'%');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -26,6 +26,9 @@ class UserController extends Controller
|
|||
'id' => $user->id,
|
||||
'phone' => $user->phone,
|
||||
'user_info' => UserInfoResource::make($user->userInfo),
|
||||
'is_vip' => $user->isVip(),
|
||||
'wallet' => UserWalletResource::make($user->wallet),
|
||||
'balance' => UserBalanceResource::make($user->balance),
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,67 @@
|
|||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Models\{User, Order, SalesValueLog};
|
||||
|
||||
/**
|
||||
* 分销模块
|
||||
*/
|
||||
class DistributeService
|
||||
{
|
||||
public static $levels = [
|
||||
'favoite' => [
|
||||
['name' => '金', 'level' => 'v3'],
|
||||
['name' => '银', 'level' => 'v2'],
|
||||
['name' => '铜', 'level' => 'v1'],
|
||||
],
|
||||
'agent' => [
|
||||
['name' => '省', 'level' => 'v3'],
|
||||
['name' => '市', 'level' => 'v2'],
|
||||
['name' => '区', 'level' => 'v1'],
|
||||
]
|
||||
];
|
||||
|
||||
/**
|
||||
* 用户下单后, 更新成长值, 添加返现记录
|
||||
*
|
||||
* @param \App\Models\Order $order
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function storeByOrder(Order $order)
|
||||
{
|
||||
// 订单已取消
|
||||
if ($order->isCancelled) {
|
||||
return false;
|
||||
}
|
||||
// 订单成长值
|
||||
$sales_value = $order->sales_value;
|
||||
$user = $order->user;
|
||||
$user->salesValueLogs()->create([
|
||||
'order_id' => $order->id,
|
||||
'order_user_id' => $user_id,
|
||||
'type' => SalesValueLog::TYPE_INDIVIDUAL,
|
||||
'change_sales_value' => $sales_value
|
||||
]);
|
||||
$user->userInfo()->increment('growth_value', $sales_value);
|
||||
|
||||
|
||||
// 上级返现
|
||||
$parent_ids = array_reverse($user->userInfo->parent_ids);
|
||||
$parents = User::with(['userInfo'])->whereIn('id', $parent_ids)->where('role', '!=', '')->get();
|
||||
// 没有上级是代理身份
|
||||
if ($parents->count() === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$setting = new SettingService();
|
||||
$conf = $setting->get('distribution');
|
||||
foreach($parents as $item) {
|
||||
$slug = explode('-', $item->userInfo->role);
|
||||
$role = $slug[0];
|
||||
$level = $slug[1];
|
||||
$ratio = data_get($conf, $role . '-profit-' . $level);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -24,6 +24,7 @@ class DatabaseSeeder extends Seeder
|
|||
ProductPartSeeder::class,
|
||||
ProductCategorySeeder::class,
|
||||
AdAddressSeeder::class,
|
||||
ShippingSeeder::class
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use App\Models\{ShippingTemplate, ShippingRule, Zone};
|
||||
|
||||
class ShippingSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$template = ShippingTemplate::create([
|
||||
'name' => '自提'
|
||||
]);
|
||||
|
||||
ShippingRule::create([
|
||||
'template_id' => $template->id,
|
||||
'type' => 1,
|
||||
'info' => json_encode(["threshold" => "100"]),
|
||||
'zones' => json_encode(Zone::where('type', Zone::TYPE_AREA)->pluck('id')),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue