120 lines
3.7 KiB
PHP
120 lines
3.7 KiB
PHP
<?php
|
|
namespace Yunshop\WeightValue\admin;
|
|
|
|
use app\common\components\BaseController;
|
|
use app\common\helpers\PaginationHelper;
|
|
use app\common\models\Order;
|
|
use Yunshop\TeamDividend\models\TeamDividendLevelModel;
|
|
use Yunshop\WeightValue\models\WeightValue;
|
|
use Yunshop\WeightValue\models\WeightValueLog;
|
|
use app\common\facades\Setting;
|
|
use app\common\helpers\Url;
|
|
|
|
class IndexController extends BaseController{
|
|
|
|
/**
|
|
* Common: 进入权重值列表
|
|
* Author: wu-hui
|
|
* Time: 2023/10/12 15:40
|
|
* @return array|string
|
|
* @throws \Throwable
|
|
*/
|
|
public function index(){
|
|
//参数获取
|
|
$pageSize = request()->input('page_size',10);
|
|
$search = request()->input('search');
|
|
// 获取列表信息
|
|
$result = WeightValue::getList($pageSize,$search);
|
|
$data = [
|
|
'list' => $result['data'],
|
|
'pager' => PaginationHelper::show($result['total'],$result['current_page'],$result['per_page']),
|
|
'search' => $search,
|
|
'level_list' => TeamDividendLevelModel::getAll(['id','level_name'])
|
|
];
|
|
|
|
return view('Yunshop\WeightValue::index.index',$data)->render();
|
|
}
|
|
/**
|
|
* Common: 查看变更记录
|
|
* Author: wu-hui
|
|
* Time: 2023/10/16 17:48
|
|
* @return array|\Illuminate\Http\JsonResponse|string
|
|
* @throws \Throwable
|
|
*/
|
|
public function changeRecord(){
|
|
// 参数获取
|
|
$memberId = (int)request()->input('member_id');
|
|
$levelId = (int)request()->input('level_id');
|
|
$isGet = (int)request()->input('is_get');
|
|
$search = request()->input('search');
|
|
if($isGet){
|
|
// 获取变更记录
|
|
$field = [
|
|
'id',
|
|
'team_dividend_agency_level_id',
|
|
'change_type',
|
|
'change_quantity',
|
|
'change_front',
|
|
'change_after',
|
|
'remark',
|
|
'created_at'
|
|
];
|
|
$result = WeightValueLog::getList(10,$search,$field);
|
|
|
|
return $this->successJson('success',[
|
|
'current_page' => $result['current_page'],
|
|
'data' => $result['data'],
|
|
'last_page' => $result['last_page'],
|
|
]);
|
|
}
|
|
|
|
return view('Yunshop\WeightValue::index.change_record',[
|
|
'member_id' => $memberId,
|
|
'level_id' => $levelId,
|
|
'is_get' => $isGet,
|
|
])->render();
|
|
}
|
|
/**
|
|
* Common: 设置信息编辑
|
|
* Author: wu-hui
|
|
* Time: 2023/10/20 14:33
|
|
* @return array|mixed|string|void
|
|
* @throws \Throwable
|
|
*/
|
|
public function set(){
|
|
// 获取设置信息 判断是否为设置
|
|
$setInfo = request()->input('weight_value');
|
|
if ($setInfo) {
|
|
// 信息校验
|
|
if((int)$setInfo['is_open_commission'] == 1 && ((float)$setInfo['commission'] <= 0 || (float)$setInfo['commission'] > 100)){
|
|
return $this->message('手续费比例填写错误','','error');
|
|
}
|
|
// 设置信息
|
|
if (Setting::set('plugin.weight_value', $setInfo)) return $this->message('设置成功', Url::absoluteWeb('plugin.weight-value.admin.index.set'));
|
|
else $this->message('设置失败','','error');
|
|
}else{
|
|
// 获取信息
|
|
$set = Setting::get('plugin.weight_value');
|
|
|
|
return view('Yunshop\WeightValue::index.set',[
|
|
'set' => $set,
|
|
])->render();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
public function test(){
|
|
// (new WeightValue())->upgradeGiveInit(1,1);
|
|
// (new WeightValue())->giveInit(Order::find(128));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|