Commit 7b195abd by mushishixian

校验审核银行信息

parent 95413a20
......@@ -64,23 +64,27 @@ class SupplierReceiptApiController extends Controller
$supplierId = $request->get('supplier_id');
$model = new SupplierReceiptModel();
if (!empty($receiptId)) {
$oldReceipt = $model->where('receipt_id', $receiptId)->first()->toArray();
$result = $model->where('receipt_id', $receiptId)->update($receipt);
} else {
$oldReceipt = [];
$receipt['supplier_id'] = $supplierId;
$result = $model->insert($receipt);
$result = $model->insertGetId($receipt);
$receiptId = $result;
}
if ($result) {
$newReceipt = $model->where('receipt_id', $receiptId)->first()->toArray();
//如果修改的只是备注,则不需要转成审核
$needAudit = $this->checkNeedAudit($oldReceipt, $newReceipt);
if ($needAudit || empty($request->get('receipt_id'))) {
$supplierModel = new SupplierChannelModel();
$supplierStatus = $supplierModel->where('supplier_id',$supplierId)->value('status');
//不等于-1的时候是第一次新增供应商,单独银行信息,不需要修改状态
if ($supplierStatus != SupplierChannelModel::STATUS_PENDING) {
//供应商变成待审核
$supplierModel = new SupplierChannelModel();
//修改供应商为审核状态
$supplierModel->where('supplier_id', $supplierId)->update([
'update_time' => time(),
'status' => 1,
]);
}
$logService = new LogService();
$content = !empty($receipt['receipt_id']) ? '修改银行信息' : '添加银行信息';
$remark = json_encode($receipt);
......@@ -90,6 +94,24 @@ class SupplierReceiptApiController extends Controller
$this->response(-1, '操作失败');
}
//判断是否要进入待审核状态,因为部分字段修改是不需要走审核的
private function checkNeedAudit($oldReceipt, $newReceipt)
{
$notNeedAuditField = [
'remark',
];
$diff = array_diff($oldReceipt, $newReceipt);
unset($diff['update_time']);
$changeField = array_keys($diff);
foreach ($changeField as $filed) {
//只要有一个不存在于不需要审核的字段,就返回需要审核
if (!in_array($filed, $notNeedAuditField)) {
return true;
}
}
return false;
}
//删除
public function DeleteSupplierReceipt($request)
{
......
......@@ -22,7 +22,6 @@ class ReceiptValidator
// "account_name" => "required",
"certificate" => "required",
];
$receipt['certificate'] = '111';
if ($receipt['receipt_type'] == 2) {
$rules["swift_code"] = 'required';
}
......
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