Commit 6c835da4 by 杨树贤

判断地址修改同步以及广播兼容地址判断

parent 4dad90cf
......@@ -332,8 +332,8 @@ class SupplierApiController extends Controller
//如果是编辑操作,则要忽略非当前
if ($supplierId) {
$originSupplierName = $model->where('supplier_id', $supplierId)->value('supplier_name');
$existedSupplierName = $model->where('supplier_name', $supplierName)->where('supplier_name', '!=',
$originSupplierName)
$existedSupplierName = $model->where('supplier_name', $supplierName)
->where('supplier_name', '!=', $originSupplierName)
->value('supplier_name');
if ($supplierName !== $existedSupplierName) {
......
......@@ -92,6 +92,7 @@ class CompanyService
'create_uid' => request()->user->userId,
'create_name' => request()->user->name,
'source_system_id' => 1,
'address_data' => [],
];
$url = config('website.UnitedDataDomain') . '/sync/Company/checkCompanyEntity';
$result = curl($url, $params);
......
......@@ -600,10 +600,12 @@ class DataService
public static function checkSupplierBandAccount()
{
ini_set('memory_limit', -1);
$accounts = SupplierReceiptModel::select(['account_no', 'supplier_id'])->get()->toArray();
$accounts = SupplierReceiptModel::select(['account_no', 'supplier_id','bank_adderss'])->get()->toArray();
foreach ($accounts as $account) {
if (!SupplierReceiptService::isOnlyDigitsAndHyphen($account['account_no'])) {
if (!SupplierReceiptService::checkAccountNo($account['account_no'])) {
dump($account['account_no']);
$accountNo = SupplierReceiptService::transferAccountNo($account['account_no']);
dump($accountNo,$account['bank_adderss']);
}
}
}
......
......@@ -8,6 +8,7 @@ use App\Model\LogModel;
use App\Model\SupplierAddressModel;
use App\Model\SupplierChannelModel;
use App\Model\SupplierContactModel;
use http\Exception\InvalidArgumentException;
class SupplierAddressService
{
......@@ -52,7 +53,7 @@ class SupplierAddressService
}
//保存发货地址
public function saveShippingAddress($supplierId,$address)
public function saveShippingAddress($supplierId, $address)
{
$supplierModel = new SupplierChannelModel();
$supplierCode = $supplierModel->where('supplier_id', $supplierId)->value('supplier_code');
......@@ -66,4 +67,67 @@ class SupplierAddressService
$addressModel = new SupplierAddressModel();
$addressModel->insert($shippingData);
}
}
\ No newline at end of file
//更新一体化的地址库
public function updateUnitedAddress($supplierId, $supplierAddress, $shippingAddress, $returnAddress)
{
//先找出原始地址数据,然后比对
$supplier = SupplierChannelModel::where('supplier_id', $supplierId)->select([
'supplier_id',
'supplier_code',
'supplier_address',
'create_name',
'create_uid',
]);
$oldSupplierAddress = $supplier['supplier_address'];
//收发货地址
$addressData = SupplierAddressModel::where('supplier_id', $supplierId)->pluck('address', 'address_type')->toArray();
//发货地址
$oldShippingAddress = array_get($addressData, 1);
//退货地址
$oldReturnAddress = array_get($addressData, 2);
//比较,如果有变化,则请求一体化接口
$changedAddress = [];
if ($oldSupplierAddress != $supplierAddress) {
$changedAddress[] = [
'source_id' => $supplierId,
'source_code' => $supplierId,
'address_type' => '供应商地址',
'address' => $supplierAddress,
];
}
if ($oldShippingAddress != $shippingAddress) {
$changedAddress[] = [
'source_id' => $supplierId,
'source_code' => $supplierId,
'address_type' => '供应商收货地址',
'address' => $shippingAddress,
];
}
if ($oldReturnAddress != $returnAddress) {
$changedAddress[] = [
'source_id' => $supplierId,
'source_code' => $supplierId,
'address_type' => '供应商退货地址',
'address' => $returnAddress,
];
}
//构建修改地址库请求数据
$params = [
'company_name_cn' => $supplier['supplier_name'],
'business_license' => '',
'source_system_id' => 1,
'create_uid' => $supplier['create_uid'],
'create_name' => $supplier['create_name'],
'address_data' => $changedAddress,
];
$url = config('website.UnitedDataDomain') . '/sync/updateAddress';
$result = curl($url, $params);
$result = json_decode($result, true);
if (array_get($result, 'code') != 0) {
\Log::error('更新一体化地址库失败 : ' . json_encode($result));
}
}
}
......@@ -11,7 +11,13 @@ use App\Model\SupplierContactModel;
class SupplierReceiptService
{
public static function isOnlyDigitsAndHyphen($str) {
return preg_match("/^[0-9\-]*$/", $str);
//判断字符串是否自由数字、英文字母、字符“-”和“()”
public static function checkAccountNo($str) {
return preg_match("/^[0-9a-zA-Z\-\(\)]*$/", $str) === 1;
}
//字符串保留数字、英文字母、字符“-”和“()”
public static function transferAccountNo($str) {
return preg_replace("/[^0-9a-zA-Z\-\(\)]/", "", $str);
}
}
......@@ -118,7 +118,6 @@ class SupplierService
/**新增供应商操作**/
if (empty($channel['supplier_id'])) {
//处理附件信息,新增的时候才会有附件信息提交过来
$attachmentField = [
'file_name',
......@@ -259,9 +258,12 @@ class SupplierService
$channel['system_tags'] = trim(implode(',', $channel['system_tags']), ',');
$model->where('supplier_id', $supplierId)->update($channel);
//保存地址
$supplierAddressService = new SupplierAddressService();
$supplierAddressService->saveAddress($address);
//校验是否需要同步修改地址给一体化
$supplierAddressService->updateUnitedAddress($supplierId, $channel['supplier_address'], $address['shipping_address'], $address['return_address']);
//保存附加费
$extraFaxService = new SupplierExtraFeeService();
$extraFaxService->saveSupplierExtraFee($extraFax);
......
......@@ -202,7 +202,7 @@ class SyncSupplierService
$supplier = SupplierChannelModel::where('supplier_id', $sourceSn)->orWhere('group_code', $groupCode)->first();
$supplier = !empty($supplier) ? $supplier->toArray() : [];
$supplierId = $supplier['supplier_id'];
$supplier = SupplierChannelModel::where('supplier_id', $supplierId)->first()->toArray();
//$supplier = SupplierChannelModel::where('supplier_id', $supplierId)->first()->toArray();
//if ($companyCategory != '') {
// //实体名单和黑名单都要拉黑,如果不属于黑名单,那么就要将状态改成审核中
// if ($companyCategory == '黑名单供应商') {
......@@ -244,14 +244,17 @@ class SyncSupplierService
//接收一体化的广播信息,对供应商进行实体名单操作
//加入实体名单后,要做很多事情,比如禁用供应商,也要禁用供应商账号等等,还要记录禁用之前的状态,等到移除实体名单以后,要恢复之前的状态
public function receiveEntityResult($supplierName, $result, $tagList)
public function receiveEntityResult($resultData)
{
$supplierName = $resultData['company_name'];
$result = $resultData['result'];
$tagList = $resultData['tag_list'];
Log::warning('一体化拉黑结果 : ' . ($supplierName . '---' . $result));
//根据result,修改供应商的是否是实体名单字段
$isEntity = ($result == 1) ? false : true;
$isEntityResult = SupplierChannelModel::IS_ENTITY_FALSE; //默认不是实体名单
$resultData['warning_type'] = $resultData['warning_type'] == 1 ? '供应商名称' : '地址';
//我这里的状态和一体化的结果判断有点对不上,因为我这把是(是否实体名单),而一体化那边是实体名单是否通过,所以要转换
if ($result == 1) {
$isEntityResult = SupplierChannelModel::IS_ENTITY_FALSE;
......@@ -259,15 +262,15 @@ class SyncSupplierService
} else {
if ($result == -1) {
$isEntityResult = SupplierChannelModel::IS_ENTITY_TRUE;
$logContent = $reason = '属于实体名单,系统自动拉入黑名单';
$logContent = $reason = "属于实体名单,系统自动拉入黑名单. 风险类型 : {$resultData['warning_type']} 风险词 : {$resultData['warning_keyword']} 风险数据 : {$resultData['warning_data']}";
}
if ($result == 0) {
$isEntityResult = SupplierChannelModel::IS_ENTITY_NEED_CONFIRM;
$logContent = $reason = '待确认实体名单,系统自动拉入禁止交易,请联系“风控部门”进行确认';
$logContent = $reason = "待确认实体名单,系统自动拉入禁止交易,请联系“风控部门”进行确认. 风险类型 : {$resultData['warning_type']} 风险词 : {$resultData['warning_keyword']} 风险数据 : {$resultData['warning_data']}";
}
if ($result == -3) {
$isEntityResult = SupplierChannelModel::IS_ENTITY_REJECT;
$logContent = $reason = '被驳回供应商,系统自动拉入禁止交易,请联系“风控部门”进行确认';
$logContent = $reason = "被驳回供应商,系统自动拉入禁止交易,请联系“风控部门”进行确认. 风险类型 : {$resultData['warning_type']} 风险词 : {$resultData['warning_keyword']} 风险数据 : {$resultData['warning_data']}";
}
}
......
......@@ -3,6 +3,7 @@
namespace App\Http\Validators;
use App\Http\Services\SupplierReceiptService;
use App\Model\SupplierChannelModel;
use Validator;
......@@ -31,6 +32,22 @@ class ReceiptValidator
$messages = $this->messages();
$validator = Validator::make($receipt, $rules, $messages);
$otherErrors = [];
if (!SupplierReceiptService::checkAccountNo($receipt['account_no'])) {
if ($returnAllError) {
$otherErrors[] = '银行账号仅支持输入数字、英文字母、符号“-”“()”';
return $otherErrors;
}else{
return '银行账号仅支持输入数字、英文字母、符号“-”“()”';
}
}
if ($otherErrors) {
return $otherErrors;
}
//判断联系方式的表单验证
if ($validator->fails()) {
if ($returnAllError) {
......
......@@ -308,9 +308,9 @@ return [
'IsEntity' => [
-1 => '',
0 => '待确认',
1 => '',
-1 => '普通',
0 => '待处理',
1 => '实体名单',
-2 => '驳回'
],
......
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