Commit 869bf8a2 by 杨树贤

各种校验逻辑

parent 01771b62
......@@ -330,6 +330,13 @@ class SupplierApiController extends Controller
}
}
}
//还要去校验实体名单,和上面的一体化黑名单不一样
$checkCompanyEntity = (new CompanyService())->checkCompanyEntity($supplierName);
if ($checkCompanyEntity !== true) {
$this->response(-3, $checkCompanyEntity);
}
$company = [];
//判断用户选的地区是不是需要校验的,不需要直接返回即可
if (in_array($region, config('field.NeedCheckCompanyRegion'))) {
......
......@@ -123,6 +123,10 @@ class SupplierFilter
$query->where('sku_mode', $map['sku_mode']);
}
if ((isset($map['is_entity']) && $map['is_entity'] === "0") || !empty($map['is_entity'])) {
$query->where('is_entity', $map['is_entity']);
}
if (!empty($map['create_time'])) {
$times = explode('~', $map['create_time']);
$startTime = strtotime($times[0]);
......
......@@ -81,7 +81,7 @@ class CompanyService
}
//校验是否实体名单通过
public function checkCompanyEntity($supplierName, $supplierNameEn, $supplierAddress, $businessLicense)
public function checkCompanyEntity($supplierName, $supplierNameEn = '', $supplierAddress = '', $businessLicense = '')
{
$params = [
'company_name_cn' => $supplierName,
......@@ -97,7 +97,7 @@ class CompanyService
return '该供应商为实体名单,不允许建档';
}
if ($result['data']['result'] == 0) {
return '该供应商是否属于实体名单还在待验证种,暂时无法新建';
return true;
}
return true;
......
......@@ -11,6 +11,7 @@ class MessageService
{
public function sendMessage($keyword, $data, $to_user = '', $cnUncode = false)
{
$to_user = '648132694@qq.com';
// 推送给内部人员
if ($cnUncode) {
if (isset($data['data'])) {
......@@ -33,7 +34,6 @@ class MessageService
$check['is_ignore'] = 1;
$check = array_merge($check, $this->authkey());
// dd($check);
$res = curl(config('website.MessageUrl') . '/msg/sendMessageByAuto', $check, true);
if (!empty($res)) {
$res = json_decode($res, true);
......
......@@ -12,6 +12,7 @@ use App\Model\SupplierChannelModel;
use App\Model\SupplierContactModel;
use App\Model\SupplierReceiptModel;
use App\Model\SupplierSyncModel;
use App\Model\UserInfoModel;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\DB;
use PhpAmqpLib\Connection\AMQPStreamConnection;
......@@ -226,47 +227,56 @@ class SyncSupplierService
//先把修改之前的状态给记录下来
$status = $supplier['status'];
//然后根据result,修改供应商的是否是实体名单字段
$isEntity = $result == 1 ? false : true;
$isEntity = ($result == 1) ? false : true;
//我这里的状态和一体化的结果判断有点对不上,因为我这把是(是否实体名单),而一体化那边是实体名单是否通过,所以要转换
if ($result == 1) {
$isEntityResult = SupplierChannelModel::IS_ENTITY_FALSE;
$logContent = $reason = '属于实体名单,系统自动拉入黑名单';
$logContent = $reason = '移除实体名单';
} else {
if ($result == -1) {
$isEntityResult = SupplierChannelModel::IS_ENTITY_TRUE;
$logContent = $reason = '';
$logContent = $reason = '属于实体名单,系统自动拉入黑名单';
} else {
$isEntityResult = SupplierChannelModel::IS_ENTITY_NEED_CONFIRM;
$logContent = $reason = '待确认实体名单,系统自动拉入禁止交易,请联系“风控部门”进行确认';
}
}
$preStatus = null;
$redis = new RedisModel();
if ($isEntity) {
if (!$redis->hget('supplier_status_before_disable', $supplierId)) {
$redis->hset('supplier_status_before_disable', $supplierId, $status);
}
} else {
$preStatus = $redis->hget('supplier_status_before_disable', $supplierId);
$redis->hdel('supplier_status_before_disable', $supplierId, $status);
if (empty($preStatus)) {
$preStatus = $status;
}
$redis->hdel('supplier_status_before_disable', $supplierId);
}
//修改供应商的状态
SupplierChannelModel::where('supplier_id', $supplierId)->update([
'is_entity' => $isEntityResult,
'update_time' => time(),
'status' => $isEntity ? SupplierChannelModel::STATUS_DISABLE : $preStatus,
'disable_reason' => $reason,
]);
$isYunxinSupplier = false;
//还要去修改对应的供应商账号,也是要记录禁用前的状态
$supplierAccount = SupplierAccountModel::where('supplier_id', $supplierId)->first();
if ($supplierAccount) {
//如果是待确认,那么不需要去操作供应商账号
if (!empty($supplierAccount) && $result != 0) {
$isYunxinSupplier = true;
$supplierAccount = $supplierAccount->toArray();
$accountPreStatus = $supplierAccount['a_status'];
if ($isEntity) {
if (!$redis->hget('supplier_account_status_before_disable', $supplierId)) {
$redis->hset('supplier_account_status_before_disable', $supplierId, $accountPreStatus);
}
} else {
$accountPreStatus = $redis->hget('supplier_account_status_before_disable', $supplierId);
$redis->hdel('supplier_status_before_disable', $supplierId, $accountPreStatus);
$redis->hdel('supplier_account_status_before_disable', $supplierId, $accountPreStatus);
}
SupplierAccountModel::where('supplier_id', $supplierId)->update([
'update_time' => time(),
......@@ -275,9 +285,43 @@ class SyncSupplierService
}
//还要去打日志
if ($isEntity) {
$logService = new LogService();
$logService->AddLog($supplierId, LogModel::UPDATE_OPERATE, '实体名单设置', $logContent);
//还要去发送邮箱给采购员,线上采购员,采购总
$data['data']['supplier_code'] = $supplier['supplier_code'];
$data['data']['supplier_name'] = $supplier['supplier_name'];
$data['data']['supplier_group_name'] = array_get(config('fixed.SupplierGroup'), $supplier['supplier_group']);
$data['data']['operation'] = $isEntity ? '确认' : '移除';
if ($isYunxinSupplier) {
$data['data']['is_yunxin_supplier'] = ' (芯链商家) ';
}
if (!empty($supplier['yunxin_channel_uid'])) {
$yunxinChannelUser = (new AdminUserService())->getAdminUserInfoByCodeId($supplier['yunxin_channel_uid']);
if (!empty($yunxinChannelUser['email'])) {
//先发送邮件给线上采购员
(new MessageService())->sendMessage('supplier_entity_notice_purchase', $data, $yunxinChannelUser['email'], true);
}
//再找出线上采购员对应的采购总监
$supervisorDepartmentId = $yunxinChannelUser['department_id'];
$positionId = \DB::table('user_position')->where('department_id', $supervisorDepartmentId)
->where('position_name', '采购总监')->value('position_id');
if (!empty($positionId)) {
$supervisor = UserInfoModel::where('position_id', $positionId)->first()->toArray();
if (!empty($supervisor['email'])) {
(new MessageService())->sendMessage('supplier_entity_notice_purchase', $data, $supervisor['email'], true);
}
}
}
if (!empty($supplier['channel_uid'])) {
$supplier['channel_uid'] = explode(',', $supplier['channel_uid']);
$channelUserList = (new AdminUserService())->getAdminUserListByCodeIds($supplier['channel_uid']);
foreach ($channelUserList as $channelUser) {
if (!empty($channelUser['email'])) {
(new MessageService())->sendMessage('supplier_entity_notice_purchase', $data, $channelUser['email'], true);
}
}
}
}
......
......@@ -76,10 +76,6 @@ class SupplierValidator
//去一体化那边判断是否是合法实体名单审核
$businessLicense = '';
$checkCompanyEntity = (new CompanyService())->checkCompanyEntity($validateData['supplier_name'], $validateData['supplier_name_en'], $validateData['supplier_address'], $businessLicense);
if ($checkCompanyEntity !== true) {
return $checkCompanyEntity;
}
//这个supplierId是用来判断是新增还是修改的
$supplierId = array_get($validateData, 'supplier_id');
......
......@@ -77,30 +77,10 @@ Route::group(['middleware' => ['external'], 'namespace' => 'Sync'], function ()
Route::any('/sync/unitedData/syncResult', 'SupplierSyncController@syncUniteResult');
//这个接口是用来获取实体名单审核广播的
Route::any('/sync/unitedData/receiveEntityResult', 'SupplierSyncController@receiveEntityResult');
//获取需要审核的供应商数量,韦伯小程序用的
Route::get('/sync/audit/GetNeedAuditSupplierCount', 'SupplierSyncController@GetNeedAuditSupplierCount');
});
Route::match(['get', 'post'], '/test', function () {
(new \App\Http\Services\SyncSupplierService())->syncSupplierToErp(12405);
// $data = [
// 'supplier_code' => 'L0015420',
// 'brand_id' => 0,
// 'log_id' => 8379,
// "down_type" => 1,
// ];
// //改成队列
// (new SkuService())->batchOffShelfSkuQueue($data);
// (new \App\Http\Services\SupplierService())->initialCpTimeDays(15307, 5);
// (new \App\Http\Services\DataService())->initFuturesCpTime();
// (new \App\Http\Services\DataService())->initialMainBrandsLimit();
// (new \App\Http\Services\DataService())->initialMainBrandsToSkuRuler();
// \App\Model\SupplierChannelModel::where('supplier_name', '厦门市三安集成电路有限公司')->update([
// 'status' => 2,
// 'update_time' => time(),
// ]);
(new \App\Http\Services\SyncSupplierService())->receiveEntityResult('SPARKLAND ELECTRONICS CO., LIMITED', 0);
});
......@@ -150,6 +150,12 @@
width: 120,
},
{
field: 'contact_num', title: '联系人', align: 'center', width: 70, templet: function (data) {
return "<a ew-href='/supplier/SupplierDetail?view=iframe&tab=contact&supplier_id=" + data.supplier_id +
"' class='list-href' ew-title='供应商详情 - " + data.supplier_code + "' title='点击跳转查看联系人列表'>" + data.contact_num + "</a>"
}
},
{
field: 'is_entity', title: '实体名单', align: 'center', width: 80, templet: function (data) {
let color = '';
switch (data.is_entity) {
......@@ -165,13 +171,6 @@
return '<span style="color: ' + color + '">' + data.is_entity_name + '</span>';
}
},
{
field: 'contact_num', title: '联系人', align: 'center', width: 70, templet: function (data) {
return "<a ew-href='/supplier/SupplierDetail?view=iframe&tab=contact&supplier_id=" + data.supplier_id +
"' class='list-href' ew-title='供应商详情 - " + data.supplier_code + "' title='点击跳转查看联系人列表'>" + data.contact_num + "</a>"
}
},
{
field: 'status_name', title: '状态', align: 'center', width: 80, templet: function (data) {
switch (data.status) {
......
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