Commit 54833dee by 杨树贤

禁用启用删除子账号

parent be171628
...@@ -186,9 +186,9 @@ class SupplierAccountApiController extends Controller ...@@ -186,9 +186,9 @@ class SupplierAccountApiController extends Controller
if ($validator->fails()) { if ($validator->fails()) {
$this->response(-1, $validator->errors()->first()); $this->response(-1, $validator->errors()->first());
} }
$data['user_rule'] = $data['user_rule']?:[]; $data['user_rule'] = $data['user_rule'] ?: [];
$data['user_rule'] = json_encode($data['user_rule']); $data['user_rule'] = json_encode($data['user_rule']);
$data['user_message_rule'] = $data['user_message_rule']?:[]; $data['user_message_rule'] = $data['user_message_rule'] ?: [];
$data['user_message_rule'] = json_encode($data['user_message_rule']); $data['user_message_rule'] = json_encode($data['user_message_rule']);
$accountId = $data['account_id']; $accountId = $data['account_id'];
unset($data['account_id']); unset($data['account_id']);
...@@ -205,18 +205,17 @@ class SupplierAccountApiController extends Controller ...@@ -205,18 +205,17 @@ class SupplierAccountApiController extends Controller
} }
} }
//禁用子账号 //修改子账号状态
public function DisableSupplierSubAccount($request) public function ChangeSupplierSubAccountStatus($request)
{ {
$id = $request->get('id'); $accountId = $request->input('account_id');
$model = new SupplierAccountModel(); $sbatId = $request->input('sbat_id');
$data['update_time'] = date('Y-m-d H:i:s'); $status = $request->input('status');
$data['a_status'] = 0; $result = (new SupplierSubAccountService())->changeSupplierSubAccountStatus($accountId, $sbatId, $status);
$result = $model->where('id', $id)->update($data);
if ($result) { if ($result) {
$this->response(0, '禁用成功'); $this->response(0, '操作成功');
} }
$this->response(-1, '禁用失败', $result); $this->response(-1, '操作失败', $result);
} }
//删除子账号 //删除子账号
......
...@@ -91,7 +91,7 @@ class SupplierSubAccountService ...@@ -91,7 +91,7 @@ class SupplierSubAccountService
$params = $this->generateRequestAuthData($accountId); $params = $this->generateRequestAuthData($accountId);
if ($sbatId) { if ($sbatId) {
$params['sbat_id'] = $sbatId; $params['sbat_id'] = $sbatId;
}else{ } else {
$params['method'] = 'add'; $params['method'] = 'add';
} }
$result = json_decode(curl($url, $params), true); $result = json_decode(curl($url, $params), true);
...@@ -158,11 +158,13 @@ class SupplierSubAccountService ...@@ -158,11 +158,13 @@ class SupplierSubAccountService
//修改子账号状态 //修改子账号状态
//1启动2禁用0删除 //1启动2禁用0删除
public function changeSupplierSubAccountStatus($accountId, $status) public function changeSupplierSubAccountStatus($accountId, $sbatId, $status)
{ {
$url = config('website.CloudUrl') . '/inner/subAccount/changeStatus'; $url = config('website.CloudUrl') . '/inner/subAccount/changeStatus';
$params = $this->generateRequestAuthData($accountId); $params = $this->generateRequestAuthData($accountId);
$result = json_decode(curl($url, $params), true); $params['status'] = $status;
$params['sbat_id'] = $sbatId;
$result = json_decode(curl($url, $params, true), true);
if (isset($result['code']) && $result['code'] == 0) { if (isset($result['code']) && $result['code'] == 0) {
return true; return true;
} }
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
{field: 'create_type_cn', title: '创建人', align: 'center', width: 150}, {field: 'create_type_cn', title: '创建人', align: 'center', width: 150},
{field: 'create_time_cn', title: '创建时间', align: 'center', width: 150}, {field: 'create_time_cn', title: '创建时间', align: 'center', width: 150},
{field: 'update_time_cn', title: '修改时间', align: 'center', width: 150}, {field: 'update_time_cn', title: '修改时间', align: 'center', width: 150},
{field: 'operate', title: '操作', align: 'left', templet: '#edit'},
]; ];
let currentPage = 0; let currentPage = 0;
table.render({ table.render({
...@@ -45,93 +46,103 @@ ...@@ -45,93 +46,103 @@
} }
}); });
//启用 table.on('tool(supplierSubAccountList)', function (obj) {
$("#enable_supplier_sub_account").click(function () { let event = obj.event;
let checkStatus = table.checkStatus('supplierSubAccountList'); let sbatId = obj.data.sbat_id;
let data = checkStatus.data; let ynatId = obj.data.ynat_id;
if (!data.length) { let accountId = getQueryVariable('account_id');
layer.msg('请先选择要操作的供应商账号', {icon: 5}) if (event === 'detail') {
} else { layer.open({
layer.confirm('确定要启用该供应商账号吗?', function (index) { type: 2,
let id = data[0].id; area: ['95%', '95%'],
let res = ajax('/api/supplier_account/EnableSupplierSubAccount', {id: id}) fixed: false,
if (res.err_code === 0) { title: '编辑子账号',
table.reload('supplierSubAccountList'); content: '/supplier_account/SaveSupplierSubAccount?view=iframe&account_id=' + accountId + '&sbat_id=' + sbatId + '&ynat_id=' + ynatId,
layer.closeAll(); end: function () {
layer.msg(res.err_msg, {icon: 6}) table.reload('supplierSubAccountList', {
} else { page: {
layer.msg(res.err_msg, {icon: 5}) curr: 1 //重新从第 1 页开始
} },
}); });
} }
}); });
}
//禁用 if (event === 'delete') {
$("#disable_supplier_sub_account").click(function () { layer.confirm('你确定要删除该子账号吗?', {
let checkStatus = table.checkStatus('supplierSubAccountList'); btn: ['确定', '取消'] //按钮
let data = checkStatus.data; }, function (index) {
if (!data.length) { const url = '/api/supplier_account/ChangeSupplierSubAccountStatus';
layer.msg('请先选择要操作的供应商账号', {icon: 5}) const data = {
} else { account_id: accountId,
layer.confirm('确定要禁用该供应商账号吗?', function (index) { sbat_id: sbatId,
let id = data[0].id; status: 0,
let res = ajax('/api/supplier_account/DisableSupplierSubAccount', {id: id}) };
if (res.err_code === 0) {
table.reload('supplierSubAccountList');
layer.closeAll(); layer.closeAll();
layer.msg(res.err_msg, {icon: 6}) $.post(url, data, function (res) {
} else { res = JSON.parse(res);
layer.msg(res.err_msg, {icon: 5}) if (res.code === 0) {
table.reload('supplierSubAccountList');
layer.msg("删除成功", {icon: 6});
} }
}); });
}
}); });
}
//根据供应商编码已经品牌等去基石调用接口下架 if (event === 'enable') {
$("#add_supplier_sub_account").click(function () { layer.confirm('你确定要启用该子账号吗?', {
layer.open({ btn: ['确定', '取消'] //按钮
type: 2, }, function (index) {
content: '/supplier_account/SaveSupplierSubAccount?view=iframe&account_id='+getQueryVariable('account_id'), const url = '/api/supplier_account/ChangeSupplierSubAccountStatus';
area: ['70%', '80%'], const data = {
title: '添加供应商账号', account_id: accountId,
end: function () { sbat_id: sbatId,
status: 1,
};
layer.closeAll();
$.post(url, data, function (res) {
res = JSON.parse(res);
if (res.code === 0) {
table.reload('supplierSubAccountList'); table.reload('supplierSubAccountList');
// supplierStatistics(); layer.msg("启用成功", {icon: 6});
} }
}); });
}); });
$("#updateSupplierAccountPerm").click(function () { }
layer.open({
type: 2, if (event === 'disable') {
content: '/supplier_sub_account/AddSupplierSubAccount?view=iframe', layer.confirm('你确定要禁用该子账号吗?', {
area: ['800px', '600px'], btn: ['确定', '取消'] //按钮
title: '添加供应商账号', }, function (index) {
end: function () { const url = '/api/supplier_account/ChangeSupplierSubAccountStatus';
const data = {
account_id: accountId,
sbat_id: sbatId,
status: 2,
};
layer.closeAll();
$.post(url, data, function (res) {
res = JSON.parse(res);
if (res.code === 0) {
console.log(res.code);
table.reload('supplierSubAccountList'); table.reload('supplierSubAccountList');
// supplierStatistics(); layer.msg("禁用成功", {icon: 6});
} }
}); });
}); });
}
});
$("#update_supplier_sub_account").click(function () {
let checkStatus = table.checkStatus('supplierSubAccountList'); $("#add_supplier_sub_account").click(function () {
let data = checkStatus.data;
if (!data.length) {
layer.msg('请先选择要操作的供应商', {icon: 5})
} else {
let id = data[0].id;
layer.open({ layer.open({
type: 2, type: 2,
content: '/supplier_sub_account/UpdateSupplierSubAccount?view=iframe&id=' + id, content: '/supplier_account/SaveSupplierSubAccount?view=iframe&account_id=' + getQueryVariable('account_id'),
area: ['800px', '600px'], area: ['70%', '80%'],
title: '批量下架SKU', title: '添加供应商账号',
end: function () { end: function () {
table.reload('supplierSubAccountList'); table.reload('supplierSubAccountList');
// supplierStatistics();
} }
}); });
}
}); });
......
...@@ -73,5 +73,18 @@ ...@@ -73,5 +73,18 @@
<table class="layui-table" id="supplierSubAccountList" lay-filter="supplierSubAccountList"></table> <table class="layui-table" id="supplierSubAccountList" lay-filter="supplierSubAccountList"></table>
</div> </div>
<script type="text/html" id="edit">
<button class="layui-btn layui-btn-xs"
lay-event="detail" value="@{{ d.id }}"><strong>详情</strong></button>
@{{# if(d.status == 1){ }}
<button class="layui-btn layui-btn-xs layui-btn-outline layui-btn-danger" lay-event="disable"><strong>禁用</strong>
</button>
@{{# }else{ }}
<button class="layui-btn layui-btn-xs layui-btn-outline" lay-event="enable"><strong>启用</strong></button>
@{{# } }}
<button class="layui-btn layui-btn-xs layui-btn-danger delete" lay-event="delete" value="@{{ d.id }}">
<strong>删除</strong></button>
</script>
<script> <script>
</script> </script>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment