Commit d87b5672 by 杨树贤

修复bug

parent d571c55d
......@@ -7,6 +7,7 @@ use App\Http\Controllers\Filter\SupplierFilter;
use App\Http\Services\AdminUserService;
use App\Http\Services\SupplierApplyService;
use App\Http\Services\SupplierService;
use App\Model\SupplierAccountModel;
use App\Model\SupplierChannelModel;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;
......@@ -76,6 +77,11 @@ class ExternalApiController extends Controller
if ($canApplySupplier !== true) {
$this->externalResponse(-1, $canApplySupplier);
}
//判断这个手机号对应的云芯账号是否已经存在
$existAccount = SupplierAccountModel::where('mobile', $data['mobile'])->exists();
if ($existAccount) {
$this->externalResponse(-1, '该手机号已经有对应的云芯账号,请重新选择手机号');
}
$result = (new SupplierApplyService())->applySupplier($data);
if (!$result) {
$this->externalResponse(-1, '申请供应商失败');
......
......@@ -45,6 +45,12 @@ class SupplierApplyApiController extends Controller
}
$applyId = $request->get('id');
$service = new SupplierApplyService();
if ($status == SupplierApplyModel::STATUS_PASS) {
$check = $service->checkCanAuditSupplierApply($applyId);
if ($check !== true) {
$this->response(-1,$check);
}
}
$result = $service->auditSupplierApply($applyId, $status, $rejectReason);
if (!$result) {
$this->response(-1, '审核失败');
......
......@@ -64,6 +64,16 @@ class SupplierApplyService
return SupplierApplyModel::insert($data);
}
public function checkCanAuditSupplierApply($applyId)
{
$supplierId = SupplierApplyModel::where('id', $applyId)->value('supplier_id');
$status = SupplierChannelModel::where('supplier_id', $supplierId)->value('status');
if ($status != SupplierChannelModel::STATUS_PASSED) {
return "该申请对应的供应商不是通过状态,请检查该供应商的状态";
}
return true;
}
//审核供应商申请
public function auditSupplierApply($applyId, $status, $auditReason)
{
......@@ -89,7 +99,6 @@ class SupplierApplyService
'create_time' => time(),
'a_type' => 1,
'create_uid' => 1000,
'create_name' => 'admin',
'source' => 2,
]);
}else{
......@@ -116,7 +125,7 @@ class SupplierApplyService
$data = [];
$data['data']['title'] = $message;
(new MessageService())->sendMessage('supplier_apply_audit_mobile', $data, $apply['mobile'], true);
(new MessageService())->sendMessage('supplier_apply_audit_email', '【猎芯网】'.$data, $apply['email'], true);
(new MessageService())->sendMessage('supplier_apply_audit_email', $data, $apply['email'], true);
}
return $result;
}
......
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