|
@@ -4,12 +4,14 @@ namespace App\Distributor\Controllers;
|
|
|
|
|
|
use App\Distributor\Actions\SmmAddAccount;
|
|
|
use App\Distributor\Repositories\SmmUserAccount;
|
|
|
+use App\Services\SmmService;
|
|
|
use Dcat\Admin\Form;
|
|
|
use Dcat\Admin\Grid;
|
|
|
use Dcat\Admin\Show;
|
|
|
use Dcat\Admin\Http\Controllers\AdminController;
|
|
|
use Dcat\Admin\Layout\Content;
|
|
|
use Dcat\Admin\Admin;
|
|
|
+use Illuminate\Http\Request;
|
|
|
|
|
|
class SmmUserAccountController extends AdminController
|
|
|
{
|
|
@@ -33,9 +35,8 @@ class SmmUserAccountController extends AdminController
|
|
|
{
|
|
|
return Grid::make(new SmmUserAccount(), function (Grid $grid) {
|
|
|
$grid->column('id')->sortable();
|
|
|
- $grid->column('user_name');
|
|
|
+ $grid->column('title')->tree();
|
|
|
$grid->column('access_token');
|
|
|
- $grid->column('media_name');
|
|
|
$grid->column('created_at');
|
|
|
$grid->column('updated_at')->sortable();
|
|
|
$grid->filter(function (Grid\Filter $filter) {
|
|
@@ -43,16 +44,53 @@ class SmmUserAccountController extends AdminController
|
|
|
$filter->expand();
|
|
|
$filter->like('user_name')->width(2);
|
|
|
});
|
|
|
- //授权按钮
|
|
|
// 传入数组
|
|
|
$grid->rightTools([
|
|
|
- new SmmAddAccount(),
|
|
|
+ // new SmmAddAccount(),
|
|
|
]);
|
|
|
|
|
|
+ $grid->actions(function (Grid\Displayers\Actions $actions) {
|
|
|
+ $actions->disableEdit();
|
|
|
+ $actions->disableQuickEdit();
|
|
|
+ $actions->disableView();
|
|
|
+ $dist_id = $actions->row->dist_id;
|
|
|
+ if ($dist_id == 0) {
|
|
|
+ $actions->append(new SmmAddAccount());
|
|
|
+ $actions->disableDelete();
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
$grid->disableCreateButton();
|
|
|
$grid->disableEditButton();
|
|
|
- $grid->model()->where('dist_id', getDistributorId())->orderBy('media_name', 'asc')->orderBy('id', 'desc');
|
|
|
+ $grid->disableViewButton();
|
|
|
+ $grid->model()->whereIn('dist_id', [0,getDistributorId()])->orderBy('title', 'asc')->orderBy('id', 'desc');
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /*
|
|
|
+ * 社媒回调接口
|
|
|
+ */
|
|
|
+ public function callback($mediaName,Request $request)
|
|
|
+ {
|
|
|
+ try {
|
|
|
+ $ssmService = new SmmService($mediaName);
|
|
|
+ $result = $ssmService->loginCallback($request);
|
|
|
+ dd($result);
|
|
|
+ if ($result['status']) {
|
|
|
+ $accessToken = $result['data']['access_token'];
|
|
|
+ $userName = $result['data']['user_name'];
|
|
|
+ $userId = $result['data']['user_id'];
|
|
|
+ SmmUserAccount::createAccountIfMediaExists($mediaName, $userId,$userName, $accessToken);
|
|
|
+ return response()->json(['code' => 1, 'msg' => 'success']);
|
|
|
+ } else {
|
|
|
+ return response()->json(['code' => 0,'msg' => $result['data']]);
|
|
|
+ }
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ return response()->json(['code' => 0,'msg' => 'error'.$e->getMessage()]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|