Commit ba8331a1 by 杨树贤

修改供应商名称

parent 977767f5
......@@ -765,4 +765,23 @@ class SupplierApiController extends Controller
$this->response(0, 'ok', $result);
}
//修改供应商名称
public function changeSupplierName($request)
{
$supplierId = $request->input('supplier_id');
$supplierName = $request->input('supplier_name');
$supplierName = trim($supplierName);
$exist = SupplierChannelModel::where('supplier_name', $supplierName)->exists();
if ($exist) {
$this->response(-1, '该供应商名称已经存在,请修正后再提交');
}
$result = (new SupplierService())->changeSupplierName($supplierId, $supplierName);
if ($result !== true) {
$this->response(-1, $result);
}
$this->response(0, '修改供应商名称成功,请等待一体化再次审核');
}
}
......@@ -864,4 +864,42 @@ class SupplierService
return '{"allow_stock_lte_0":0,"allow_moq_lte_0":0,"allow_stock_lt_moq":0,"allow_price_null":0,"futures_allow_stock_lte_0":1,"futures_allow_moq_lte_0":0,"futures_allow_price_null":1}';
}
//修改供应商名称
public function changeSupplierName($supplierId, $supplierName)
{
$supplier = SupplierChannelModel::where('supplier_id', $supplierId)->first()->toArray();
$originSupplierName = $supplier['supplier_name'];
//修改名称,只有驳回状态下才可以修改,修改后要重新提交数据给一体化那边进行审核
$businessLicense = SupplierAttachmentsModel::where('supplier_id', $supplierId)
->where('field_name', 'business_license')->value('file_url');
$checkCompanyEntity = (new CompanyService())->checkCompanyEntity($supplierName, $supplier['supplier_name_en'], $supplier['supplier_address'], $businessLicense);
//还要去检测是否是一体化黑名单
//新增的时候要先去检验下一体化的数据,如果是实体黑名单用户,那么就不允许新增
//还要校验提交上来的公司是否有合法信息
if ($checkCompanyEntity == -1) {
return ('该供应商为实体名单,不允许修改');
}
if ($checkCompanyEntity == -2) {
return ('该供应商为黑名单,不允许修改');
}
if ($checkCompanyEntity == -3) {
return ('该供应商被驳回,不允许修改');
}
//都通过以后,可以先修改名称,然后等一体化那边审核通过
SupplierChannelModel::where('supplier_id', $supplierId)->update([
'is_entity' => SupplierChannelModel::IS_ENTITY_NEED_CONFIRM,
'supplier_name' => $supplierName,
'update_time' => time(),
]);
//打日志
$logService = new LogService();
$content = '修改供应商名称';
$msg = '供应商名称手动修改,由[ ' . $originSupplierName . ' ]修改成[ ' . $supplierName . ' ],等待一体化审核';
$logService->AddLog($supplierId, LogModel::UPDATE_OPERATE, $content, $msg);
return true;
}
}
......@@ -81,11 +81,4 @@ class SupplierChannelModel extends Model
return $this->hasMany(SupplierReceiptModel::class, 'supplier_id', 'supplier_id');
}
//获取正式供应商
public function getOfficialSuppliers()
{
return SupplierChannelModel::whereIn('is_type', 0)->get()->toArray();
}
}
......@@ -41,6 +41,28 @@
});
});
$('#change_supplier_name').click(function () {
layer.prompt({
title: '输入要修改的供应商名称',
btn: ['保存', '取消'],
}, function (supplierName, index) {
layer.msg('sdasdas', {icon: 6});
let res = ajax('/api/supplier/changeSupplierName', {
supplier_id: supplierId,
supplier_name: supplierName
})
if (res.err_code === 0) {
layer.msg(res.err_msg, {icon: 6})
setTimeout(function () {
location.reload();
}, 1000);
} else {
layer.msg(res.err_msg, {icon: 5})
return false;
}
});
});
{{--index.setTabTitle('供应商详情 - {{$supplier['supplier_code'] or ''}}');--}}
function openLogView() {
......
......@@ -93,6 +93,12 @@
{{-- class="layui-btn layui-btn">取消拉黑--}}
{{-- </button>--}}
@endif
{{-- 如果是驳回,则可以修改名称--}}
@if($supplier['is_entity'] == \App\Model\SupplierChannelModel::IS_ENTITY_REJECT && empty($supplier['group_code']))
<button id="change_supplier_name"
style="margin-bottom: 25px;margin-top: 5px" class="layui-btn layui-btn">修改名称
</button>
@endif
@endif
@if (checkPerm('PrintSupplier'))
{{--禁用和黑名单不显示打印按钮--}}
......
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