SupplierAccountController.php
5.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<?php
namespace App\Http\Controllers;
use App\Http\Services\RoleService;
use App\Http\Services\SupplierAccountService;
use App\Http\Services\SupplierContactService;
use App\Http\Services\SupplierService;
use App\Http\Services\SupplierSubAccountService;
use App\Http\Services\ViewCheckService;
use App\Model\IntracodeModel;
use App\Model\SupplierAccountModel;
use App\Model\SupplierChannelModel;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class SupplierAccountController extends Controller
{
public function info(Request $request, $id = '')
{
if ($request->path() == '/') {
$path = 'web/index';
} else {
$path = $request->path();
}
$this->data = [
'menus' => $request->menus,
'header' => $request->user->header,
'username' => $request->user->email,
'user_email' => $request->user->email,
'uri' => '/' . $path,
'id' => $id
];
return $this->$id($request);
}
public function __call($name, $arr)
{
$data['errinfo'] = '访问路径错误';
return view('errors.error', $data);
}
//操作日志列表
public function SupplierAccountList($request)
{
$this->data['title'] = '芯链账号列表';
return $this->view('芯链账号列表');
}
public function AddSupplierAccount($request)
{
//获取所有启用的供应商编码,而且类型是包括芯链
$model = new SupplierChannelModel();
$suppliers = $model->where('is_type', 0)
->whereRaw('stockup_type like "%5%"')
->where('status', SupplierChannelModel::STATUS_PASSED)
->select(['supplier_name', 'supplier_code'])->get();
$supplierCodes = [];
foreach ($suppliers as $supplier) {
$supplier = $supplier->toArray();
$supplierCodes[$supplier['supplier_code']] = $supplier['supplier_name'] . '(' . $supplier['supplier_code'] . ')';
}
$this->data['supplierCodes'] = $supplierCodes;
$this->data['title'] = '添加芯链账号';
return $this->view('添加芯链账号');
}
public function UpdateSupplierAccount($request)
{
$id = $request->get('id');
$model = new SupplierAccountModel();
$account = $model->where('id', $id)->first()->toArray();
//获取所有启用的供应商编码,而且类型是包括芯链
$model = new SupplierChannelModel();
$suppliers = $model->where('is_type', 0)
->whereRaw('stockup_type like "%5%"')
->where('status', SupplierChannelModel::STATUS_PASSED)
->select(['supplier_name', 'supplier_code'])->get();
$supplierCodes = [];
foreach ($suppliers as $supplier) {
$supplier = $supplier->toArray();
$supplierCodes[$supplier['supplier_code']] = $supplier['supplier_name'] . '(' . $supplier['supplier_code'] . ')';
}
$this->data['supplierCodes'] = $supplierCodes;
$this->data['title'] = '编辑芯链账号';
$this->data['account'] = $account;
return $this->view('编辑芯链账号');
}
//子账号列表
public function SupplierSubAccountList($request)
{
$accountId = $request->input('account_id');
if (!$accountId) {
return '账号id不能为空';
}
$supplierId = SupplierAccountModel::where('id', $accountId)->value('supplier_id');
$supplier = (new SupplierService())->getSupplier($supplierId);
$supplierAccount = (new SupplierAccountService())->getSupplierAccountBySupplierId($supplierId);
$this->data['supplier'] = $supplier;
$this->data['supplierAccount'] = $supplierAccount;
$this->data['title'] = '子账号管理';
return $this->view('子账号管理');
}
//新增修改子账号
public function SaveSupplierSubAccount($request)
{
$accountId = $request->input('account_id');
$sbatId = $request->input('sbat_id');
$ynatId = $request->input('ynat_id');
if (!empty($sbatId)) {
$account = (new SupplierSubAccountService())->getSupplierSubAccount($accountId, $sbatId);
$this->data['account'] = $account;
}
$menuPerms = (new SupplierSubAccountService())->getSupplierAccountPermList($accountId, $sbatId);
//区分主账号还是子账号保存消息权限
if ($sbatId) {
$messagePerms = (new SupplierSubAccountService())->getSupplierAccountMessagePermList($accountId, $ynatId);
} else {
$messagePerms = (new SupplierSubAccountService())->getSupplierAccountMessagePermList($accountId, $ynatId);
}
$this->data['menuPerms'] = $menuPerms;
$this->data['messagePerms'] = $messagePerms;
$this->data['title'] = '子账号编辑';
return $this->view('子账号编辑');
}
//修改主账号的消息权限
//新增修改子账号
public function SaveSupplierAccountMessagePerm($request)
{
$accountId = $request->input('account_id');
$messagePerms = (new SupplierSubAccountService())->getSupplierAccountMessagePermList($accountId, $accountId);
$this->data['messagePerms'] = $messagePerms;
$this->data['title'] = '子账号编辑';
return $this->view('子账号编辑');
}
}