Commit 20b5cee1 authored by hj's avatar hj

更新提交

parent 0900e481
...@@ -34,16 +34,14 @@ class MsdsController extends Controller ...@@ -34,16 +34,14 @@ class MsdsController extends Controller
public function getMsds(Request $request) public function getMsds(Request $request)
{ {
try{ try{
$companyCode = $request->get('company_code'); $customerCode = $request->get('customer_code');
$cusNumber = $request->get('cus_number'); if(!$customerCode){
return Response::ok('客户编号不存在!');
}
$params = $this->formatKeysfromArray($request->all(),'toUnderScore'); $params = $this->formatKeysfromArray($request->all(),'toUnderScore');
$cas = $params['cas']; $cas = $params['cas'];
$msdsType = $params['msds_type']; $msdsType = $params['msds_type'];
if(!$companyCode){
return Response::ok('验证失败,参数缺少!');
}
if(!$cas){ if(!$cas){
return Response::ok('验证失败,缺少cas参数!'); return Response::ok('验证失败,缺少cas参数!');
} }
...@@ -55,21 +53,7 @@ class MsdsController extends Controller ...@@ -55,21 +53,7 @@ class MsdsController extends Controller
return Response::ok('验证失败,获取类型错误!'); return Response::ok('验证失败,获取类型错误!');
} }
$companyInfo = app(ChemsiteCompanyService::class)->getCompanyThroughCusCode($companyCode); $platformCompanyInfo = app(CustomerService::class)->getPlatformCustomer(['cus_number' => $customerCode]);
if(!$companyInfo){
throw new ServerRunTimeException('经销商不存在');
}
if($cusNumber){
$customer = app(ChemsiteCustomerService::class)->getCustomerByNumber($cusNumber);
if(!$customer){
throw new ServerRunTimeException('客户不存在');
}
if($customer['com_id'] != $companyInfo['com_id']){
throw new ServerRunTimeException('不是该经销商的客户');
}
}
$platformCompanyInfo = app(CustomerService::class)->getPlatformCustomer(['cus_number' => $companyCode]);
$pdf = $this->chemicalsMsdsService->getMsds($cas, $msdsType, $platformCompanyInfo); $pdf = $this->chemicalsMsdsService->getMsds($cas, $msdsType, $platformCompanyInfo);
return Response::success($this->formatKeysfromArray(['download' => env('DOWNLOAD_URL').$pdf]),'操作成功'); return Response::success($this->formatKeysfromArray(['download' => env('DOWNLOAD_URL').$pdf]),'操作成功');
......
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 to comment