79 lines
2.5 KiB
PHP
79 lines
2.5 KiB
PHP
<?php
|
|
|
|
namespace Yunshop\ShareholderDividend\admin;
|
|
|
|
use app\common\components\BaseController;
|
|
use app\common\helpers\PaginationHelper;
|
|
use app\common\helpers\Url;
|
|
use Yunshop\ShareholderDividend\models\BlackListModel;
|
|
use Yunshop\TeamDividend\models\TeamDividendAgencyModel;
|
|
|
|
class BlackListController extends BaseController
|
|
{
|
|
|
|
public function index()
|
|
{
|
|
$search = request()->search;
|
|
$list = BlackListModel::search($search)->orderBy('id', 'desc')->paginate();
|
|
$pager = PaginationHelper::show($list->total(), $list->currentPage(), $list->perPage());
|
|
|
|
if (!$search['time']) {
|
|
$search['time']['start'] = date("Y-m-d H:i:s", time());
|
|
$search['time']['end'] = date("Y-m-d H:i:s", time());
|
|
$search['is_time'] = 0;
|
|
}
|
|
return view('Yunshop\ShareholderDividend::admin.black-list',[
|
|
'list' => $list,
|
|
'pager' => $pager,
|
|
'search' => $search,
|
|
])->render();
|
|
}
|
|
|
|
public function add()
|
|
{
|
|
$uid = request()->uid;
|
|
if (BlackListModel::where('member_id' ,$uid)->first()) {
|
|
return $this->message('添加失败,该会员已添加过', '', 'error');
|
|
}
|
|
$result = BlackListModel::create(['uniacid' => \YunShop::app()->uniacid,'member_id' => $uid]);
|
|
if ($result) {
|
|
return $this->message('添加成功', Url::absoluteWeb('plugin.shareholder-dividend.admin.black-list.index'));
|
|
} else {
|
|
return $this->message('添加失败', '', 'error');
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @return mixed
|
|
* 移除奖励
|
|
*/
|
|
public function remove()
|
|
{
|
|
$id = \YunShop::request()->get('id');
|
|
$agent = BlackListModel::where('id',$id)->delete();
|
|
|
|
if ($agent) {
|
|
return $this->message('移除成功', Url::absoluteWeb('plugin.shareholder-dividend.admin.black-list.index'));
|
|
} else {
|
|
return $this->message('移除失败', '', 'error');
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @return mixed
|
|
*/
|
|
public function getSearch()
|
|
{
|
|
$keyword = \YunShop::request()->keyword;
|
|
$agents = TeamDividendAgencyModel::uniacid()->whereHas('hasOneMember', function ($query) use ($keyword) {
|
|
return $query->searchLike($keyword);
|
|
})->with('hasOneMember')->get();
|
|
foreach ($agents as &$agent) {
|
|
$agent = set_medias($agent->hasOneMember, array('avatar', 'share_icon'));
|
|
}
|
|
|
|
return view('Yunshop\ShareholderDividend::admin.query', [
|
|
'agents' => $agents,
|
|
])->render();
|
|
}
|
|
} |