Commit 1e4618be by mushishixian

fix

parent 5371a058
...@@ -306,6 +306,9 @@ class SupplierApiController extends Controller ...@@ -306,6 +306,9 @@ class SupplierApiController extends Controller
$supplierIds = $request->get('supplier_ids'); $supplierIds = $request->get('supplier_ids');
$supplierIds = explode(',', $supplierIds); $supplierIds = explode(',', $supplierIds);
$supplierService = new SupplierService(); $supplierService = new SupplierService();
if (empty($purchaseUid)) {
$this->response(-1, '请选择渠道开发员');
}
$supplierService->batchAllocatePurchaseUser($supplierIds, $purchaseUid); $supplierService->batchAllocatePurchaseUser($supplierIds, $purchaseUid);
$this->response(0, '批量分配渠道员成功'); $this->response(0, '批量分配渠道员成功');
} }
...@@ -398,7 +401,7 @@ class SupplierApiController extends Controller ...@@ -398,7 +401,7 @@ class SupplierApiController extends Controller
if ($check) { if ($check) {
$this->response(0, '可以审核'); $this->response(0, '可以审核');
} else { } else {
$this->response(-1, '无法进行审核操作,因为该供应商最后修改人和您不属于同一个部门'); $this->response(-1, '无法进行审核操作,因为该供应商最后(修改人/创建人)和您不属于同一个部门');
} }
} }
} }
...@@ -150,7 +150,7 @@ class LogService ...@@ -150,7 +150,7 @@ class LogService
// $diffCols = array_diff($contact['old_contact'], $contact['new_contact']); // $diffCols = array_diff($contact['old_contact'], $contact['new_contact']);
$oldContent = $this->contactDesc($contact['old_contact']); $oldContent = $this->contactDesc($contact['old_contact']);
$newContent = $this->contactDesc($contact['new_contact']); $newContent = $this->contactDesc($contact['new_contact']);
return $oldContent . ' 修改为=> ' . $newContent; return $oldContent . ' 修改为 ' . $newContent;
} }
//新增 //新增
if (empty($contact['old_contact']) && !empty($contact['new_contact'])) { if (empty($contact['old_contact']) && !empty($contact['new_contact'])) {
......
...@@ -17,6 +17,8 @@ class SupplierAuditService ...@@ -17,6 +17,8 @@ class SupplierAuditService
{ {
$model = new SupplierChannelModel(); $model = new SupplierChannelModel();
//判断当前要审核的供应商是不是想要被禁用的 //判断当前要审核的供应商是不是想要被禁用的
//因为想要禁用,需要审核后才能禁用的,不能直接修改成禁用
//我要找个地方存起来是不是想要禁用
$redis = new RedisModel(); $redis = new RedisModel();
$disableExist = $redis->hget('audit_disable_supplier_list', $supplierId); $disableExist = $redis->hget('audit_disable_supplier_list', $supplierId);
if ($disableExist) { if ($disableExist) {
...@@ -27,14 +29,21 @@ class SupplierAuditService ...@@ -27,14 +29,21 @@ class SupplierAuditService
} }
} }
//先找出原来供应商的状态
$supplierModel = new SupplierChannelModel();
$originStatus = $supplierModel->where('supplier_id', $supplierId)->value('status');
//如果原来的状态是-1,就是第一次新增的待审核,审核通过状态是变成1(待复审)
$dbStatus = $originStatus == -1 ? 1 : $status;
$result = $model->where('supplier_id', $supplierId)->update([ $result = $model->where('supplier_id', $supplierId)->update([
'update_time' => time(), 'update_time' => time(),
'status' => $status, 'status' => $dbStatus,
'reject_reason' => $rejectReason, 'reject_reason' => $rejectReason,
]); ]);
if ($disableExist) { if ($disableExist) {
$redis->hdel('audit_disable_supplier_list', $supplierId); $redis->hdel('audit_disable_supplier_list', $supplierId);
} }
$action = '审核供应商';
if ($result) { if ($result) {
//记录日志 //记录日志
if ($disableExist) { if ($disableExist) {
...@@ -45,11 +54,17 @@ class SupplierAuditService ...@@ -45,11 +54,17 @@ class SupplierAuditService
$service->syncSupplierToErp($supplierId); $service->syncSupplierToErp($supplierId);
} }
} else { } else {
$auditStatus = $status == SupplierChannelModel::STATUS_PASSED ? '审核通过' : '审核不通过,原因是 : ' . $rejectReason; //如果原来的状态是-1,就是第一次新增的待审核,审核通过状态是变成1(待复审)
if ($originStatus == -1) {
$auditStatus = $status == SupplierChannelModel::STATUS_PASSED ? '初审通过' : '初审不通过,原因是 : ' . $rejectReason;
$action = '初审供应商';
} else {
$auditStatus = $status == SupplierChannelModel::STATUS_PASSED ? '审核通过' : '审核不通过,原因是 : ' . $rejectReason;
}
} }
$logService = new LogService(); $logService = new LogService();
$content = $auditStatus; $content = $auditStatus;
$logService->AddLog($supplierId, LogModel::UPDATE_OPERATE, '审核供应商', $content); $logService->AddLog($supplierId, LogModel::UPDATE_OPERATE, $action, $content);
} }
//审核状态为待审核(即第一次新增)时,不需要推送到金蝶 //审核状态为待审核(即第一次新增)时,不需要推送到金蝶
...@@ -65,17 +80,27 @@ class SupplierAuditService ...@@ -65,17 +80,27 @@ class SupplierAuditService
//要判断审核供应商的最后修改人,是不是属于当前审批人的部门或者部下,是才能让他审核 //要判断审核供应商的最后修改人,是不是属于当前审批人的部门或者部下,是才能让他审核
public function CheckCanAuditSupplier($supplierId) public function CheckCanAuditSupplier($supplierId)
{ {
//忽略上面所说的限制(权限)
if (checkPerm('IgnoreAuditCheck')) { if (checkPerm('IgnoreAuditCheck')) {
return true; return true;
} }
$supplierModel = new SupplierChannelModel();
$supplier = $supplierModel->where('supplier_id', $supplierId)->first()->toArray();
$auditUserId = request()->user->userId; $auditUserId = request()->user->userId;
$logModel = new LogModel(); $logModel = new LogModel();
$log = $logModel->where('supplier_id', $supplierId) $log = $logModel->where('supplier_id', $supplierId)
->where('type', LogModel::UPDATE_OPERATE)->orderBy('id', 'desc')->first(); ->where('type', LogModel::UPDATE_OPERATE)->orderBy('id', 'desc')->first()->toArray();
$lastUpdateUserId = $log['admin_id']; //判断供应商,如果是第一次新增的供应商,要去判断创建人是否属于审核人相关的部门
//别问我为啥不加多一个状态,这个审核流程是突然改成这样子的,没法加...
if ($log['action'] == '初审供应商') {
$lastUpdateUserId = $supplier['create_uid'];
} else {
$lastUpdateUserId = $log['admin_id'];
}
//审批人只能审批自己的部下修改的供应商 //审批人只能审批自己的部下修改的供应商
$departmentService = new DepartmentService(); $departmentService = new DepartmentService();
$subordinateUserIds = $departmentService->getSubordinateUserIds($auditUserId); $subordinateUserIds = $departmentService->getSubordinateUserIds($auditUserId);
if (in_array($lastUpdateUserId, $subordinateUserIds)) { if (in_array($lastUpdateUserId, $subordinateUserIds)) {
return true; return true;
} }
......
...@@ -103,7 +103,7 @@ class SupplierContactService ...@@ -103,7 +103,7 @@ class SupplierContactService
'supplier_qq', 'supplier_qq',
'supplier_fax', 'supplier_fax',
]; ];
$diff = array_diff($oldContact, $newContact); $diff = array_merge(array_diff($oldContact, $newContact), array_diff($newContact, $oldContact));
unset($diff['update_time']); unset($diff['update_time']);
$changeField = array_keys($diff); $changeField = array_keys($diff);
foreach ($changeField as $filed) { foreach ($changeField as $filed) {
......
...@@ -18,7 +18,7 @@ class ReceiptValidator ...@@ -18,7 +18,7 @@ class ReceiptValidator
"bank_name" => "required", "bank_name" => "required",
"bank_adderss" => "required", "bank_adderss" => "required",
"account_no" => "required", "account_no" => "required",
"receipt_type" => 'required',
// "account_name" => "required", // "account_name" => "required",
"certificate" => "required", "certificate" => "required",
]; ];
...@@ -37,7 +37,8 @@ class ReceiptValidator ...@@ -37,7 +37,8 @@ class ReceiptValidator
private function messages() private function messages()
{ {
return [ return [
'bank_name.required' => '开户名称不能为空', 'receipt_type.required' => '开户名称不能为空',
'bank_name.required' => '类型不能为空',
'bank_adderss.required' => '开户行不能为空', 'bank_adderss.required' => '开户行不能为空',
'swift_code.required' => '电汇号码 Swift Code 不能为空', 'swift_code.required' => '电汇号码 Swift Code 不能为空',
'account_no.required' => '银行账号不能为空', 'account_no.required' => '银行账号不能为空',
......
...@@ -24,6 +24,11 @@ class SupplierContactValidator ...@@ -24,6 +24,11 @@ class SupplierContactValidator
$messages = $this->messages(); $messages = $this->messages();
$validator = Validator::make($data, $rules, $messages); $validator = Validator::make($data, $rules, $messages);
//判断联系方式的表单验证
if ($validator->fails()) {
return $validator->errors()->first();
}
$contactModel = new SupplierContactModel(); $contactModel = new SupplierContactModel();
//如果是原厂或者代理商性质的供应商,联系人不能重复 //如果是原厂或者代理商性质的供应商,联系人不能重复
$supplierModel = new SupplierChannelModel(); $supplierModel = new SupplierChannelModel();
...@@ -46,10 +51,6 @@ class SupplierContactValidator ...@@ -46,10 +51,6 @@ class SupplierContactValidator
} }
} }
//判断联系方式的表单验证
if ($validator->fails()) {
return $validator->errors()->first();
}
} }
private function messages() private function messages()
......
...@@ -40,6 +40,40 @@ Route::group(['middleware' => ['web'], 'namespace' => 'Api'], function () { ...@@ -40,6 +40,40 @@ Route::group(['middleware' => ['web'], 'namespace' => 'Api'], function () {
Route::match(['get', 'post'], '/api/supplier_account/{key}', 'SupplierAccountApiController@Entrance'); Route::match(['get', 'post'], '/api/supplier_account/{key}', 'SupplierAccountApiController@Entrance');
}); });
Route::match(['get', 'post'], '/test', function () { Route::match(['get', 'post'], '/test', function () {
$a = [
"contact_id" => 1717,
"supplier_id" => 12253,
"supplier_consignee" => "",
"supplier_telephone" => "",
"supplier_fax" => "",
"supplier_qq" => "",
"supplier_mobile" => "",
"supplier_email" => "",
"supplier_position" => "",
"can_check_uids" => "10105",
"add_time" => 0,
"update_time" => 0,
"admin_id" => 0,
];
$b = [
"contact_id" => 1717,
"supplier_id" => 12253,
"supplier_consignee" => "延寿观呼吸",
"supplier_telephone" => "1221",
"supplier_fax" => "",
"supplier_qq" => "",
"supplier_mobile" => "18825159814",
"supplier_email" => "123@qq.com",
"supplier_position" => "测试员",
"can_check_uids" => "10105",
"add_time" => 0,
"update_time" => 1623998098,
"admin_id" => 0,
];
$diff = array_diff($b, $a);
$diff2 = array_diff($a, $b);
dd($diff,$diff2);
// set_time_limit(0); // set_time_limit(0);
// sleep(30); // sleep(30);
// echo 123; // echo 123;
......
...@@ -87,12 +87,11 @@ return [ ...@@ -87,12 +87,11 @@ return [
'SupplierStatus' => [ 'SupplierStatus' => [
// -3 => '已拉黑',
-2 => '禁止交易',
-1 => '待审核', -1 => '待审核',
1 => '待复审', 1 => '待复审',
3 => '未通过',
2 => '已通过', 2 => '已通过',
3 => '未通过' -2 => '禁止交易',
], ],
'Currency' => [ 'Currency' => [
......
...@@ -223,10 +223,10 @@ ...@@ -223,10 +223,10 @@
layer.msg('该供应商已经被审核', {icon: 5}) layer.msg('该供应商已经被审核', {icon: 5})
return return
} }
if (status === -1) { // if (status === -1) {
layer.msg('要待复审的供应商才可以审核', {icon: 5}); // layer.msg('要待复审的供应商才可以审核', {icon: 5});
return // return
} // }
let checkAuditMsg = checkCanAudit(supplierId); let checkAuditMsg = checkCanAudit(supplierId);
if (checkAuditMsg !== '') { if (checkAuditMsg !== '') {
layer.msg(checkAuditMsg, {icon: 5}); layer.msg(checkAuditMsg, {icon: 5});
...@@ -299,6 +299,12 @@ ...@@ -299,6 +299,12 @@
layer.msg('选择的供应商里,存在审核状态的供应商,无法分配渠道员', {icon: 5}) layer.msg('选择的供应商里,存在审核状态的供应商,无法分配渠道员', {icon: 5})
return return
} }
let is_type = Array.from(data, ({is_type}) => is_type);
//分配采购员的多选操作,需要先去判断是否存在审核中的供应商,存在的话,要提示
if (is_type.indexOf(1) !== -1) {
layer.msg('选择的供应商里,存在非正式供应商,请先将其转正', {icon: 5})
return
}
layer.open({ layer.open({
type: 2, type: 2,
content: '/supplier/BatchAllocatePurchaseUser?view=iframe&supplier_ids=' + supplierIds, content: '/supplier/BatchAllocatePurchaseUser?view=iframe&supplier_ids=' + supplierIds,
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
} else if (data.field.status === '-1') { } else if (data.field.status === '-1') {
confirmMessage = '确定要提交新增供应商信息吗?一旦提交,该供应商就会进入待复审阶段,审核过程中无法进行信息修改' confirmMessage = '确定要提交新增供应商信息吗?一旦提交,该供应商就会进入待复审阶段,审核过程中无法进行信息修改'
} else { } else {
confirmMessage = '确定要修改供应商信息吗?一旦修改,该供应商就会再次进入待复审阶段,审核过程中无法进行信息修改' confirmMessage = '确定要修改供应商信息吗?一旦修改关键字段,该供应商就会再次进入待复审阶段,审核过程中无法进行信息修改'
} }
layer.confirm(confirmMessage, function (index) { layer.confirm(confirmMessage, function (index) {
let res = ajax('/api/supplier/UpdateSupplier', data.field) let res = ajax('/api/supplier/UpdateSupplier', data.field)
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
<label class="layui-form-label">银行类型 : </label> <label class="layui-form-label">银行类型 : </label>
<div class="layui-input-block"> <div class="layui-input-block">
<input type="radio" name="receipt_type" lay-filter="receipt_type" value="1" title="国内" <input type="radio" name="receipt_type" lay-filter="receipt_type" value="1" title="国内"
@if(!empty($receipt['receipt_type'])&&$receipt['receipt_type']==1) @if((!empty($receipt['receipt_type'])&&$receipt['receipt_type']==1)||empty($receipt))
checked checked
@endif @endif
> >
......
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