Commit 752b8f60 by 杨树贤

Merge branch 'master' into Dev

parents c854aa5a 745bb649
......@@ -89,6 +89,7 @@ class SkuListFilter
}
if (!empty($map['data_channel_uid'])) {
$map['encoded/condition'] = $map['data_channel_uid'];
unset($map['data_channel_uid']);
}
......
......@@ -14,12 +14,10 @@ class BaseSyncController extends Controller
{
public function syncResponse($code = 0, $msg = '成功', $data = '', $count = 0)
{
header('Content-Type: application/json');
echo json_encode([
return response()->json([
'code' => $code,
'msg' => $msg,
'msg' => $msg,
'data' => $data,
]);
exit();
}
}
......@@ -52,11 +52,11 @@ class SupplierSyncController extends BaseSyncController
if ($validator->fails()) {
$error = $validator->errors()->first();
Log::warning($error);
$this->syncResponse(-1, $error);
return $this->syncResponse(-1, $error);
}
$result = (new SyncSupplierService())->syncSupplierToUnitedResult($resultData);
$this->syncResponse(0, '同步一体化信息成功');
return $this->syncResponse(0, '同步一体化信息成功');
}
public function receiveEntityResult(Request $request)
......@@ -69,11 +69,11 @@ class SupplierSyncController extends BaseSyncController
$resultData['result'] = (int)$resultData['result_map']["1"];
}
if ($resultData['result'] !== 0 && empty($resultData)) {
$this->syncResponse(-1, '没有获取到正确的类型');
return $this->syncResponse(-1, '没有获取到正确的类型');
}
if (!in_array($resultData['result'], [0, 1, -1, -2, -3])) {
$this->syncResponse(-1, '非法公司分类');
return $this->syncResponse(-1, '非法公司分类');
}
......@@ -86,8 +86,9 @@ class SupplierSyncController extends BaseSyncController
//判断联系方式的表单验证
if ($validator->fails()) {
$error = $validator->errors()->first();
$this->syncResponse(-1, $error);
return $this->syncResponse(-1, $error);
}
//这里还要去判断是是拉黑
if ($resultData['result'] == -2) {
$data['status'] = SupplierChannelModel::STATUS_BLOCK;
......@@ -96,10 +97,10 @@ class SupplierSyncController extends BaseSyncController
$data['update_time'] = time();
SupplierChannelModel::where('supplier_name', $resultData['company_name'])
->update($data);
$this->syncResponse(0, '获取审核结果广播成功');
return $this->syncResponse(0, '获取审核结果广播成功');
}
(new SyncSupplierService())->receiveEntityResult($resultData);
$this->syncResponse(0, '获取审核结果广播成功');
return $this->syncResponse(0, '获取审核结果广播成功');
}
//获取供应商需要审核的数量
......@@ -175,7 +176,7 @@ class SupplierSyncController extends BaseSyncController
if ($validator->fails()) {
$error = $validator->errors()->first();
Log::warning('[CRM同步]参数校验失败: ' . $error, $data);
$this->syncResponse(-1, $error);
return $this->syncResponse(-1, $error);
}
$customerName = trim($data['customer_name']);
......@@ -185,7 +186,7 @@ class SupplierSyncController extends BaseSyncController
// 如果状态为待确认或CRM转移供应商不通过,说明CRM重新同步了,改回待确认状态并更新信息
if (!in_array($existingSupplier['status'], [SupplierChannelModel::STATUS_CONFIRM, SupplierChannelModel::STATUS_CRM_REJECTED])) {
Log::info('[CRM同步]供应商已存在且为正式供应商,跳过: ' . $customerName);
$this->syncResponse(-1, '供应商已存在,跳过');
return $this->syncResponse(-1, '供应商已存在,跳过');
}
// 如果状态为CRM转移供应商不通过,说明CRM重新同步了,改回待确认状态并更新信息
if (
......@@ -205,11 +206,11 @@ class SupplierSyncController extends BaseSyncController
$auditService = new SupplierAuditService();
$auditService->addApproveForCustomerConvert($existingSupplier['supplier_id'], $data['apply_uid'], '客户转化供应商审核');
});
$this->syncResponse(0, 'CRM重新同步,状态已恢复为待确认并更新信息,已重新发起审核', ['supplier_id' => $existingSupplier['supplier_id']]);
return $this->syncResponse(0, 'CRM重新同步,状态已恢复为待确认并更新信息,已重新发起审核', ['supplier_id' => $existingSupplier['supplier_id']]);
LogService::AddLog($existingSupplier['supplier_id'], LogModel::UPDATE_OPERATE, 'CRM重新同步', 'CRM重新同步,状态已恢复为待确认并更新信息,已重新发起审核');
} catch (\Exception $e) {
Log::error('[CRM同步]恢复待确认状态并更新失败: ' . $e->getMessage(), ['data' => $data]);
$this->syncResponse(-1, '恢复状态并更新失败: ' . $e->getMessage());
return $this->syncResponse(-1, '恢复状态并更新失败: ' . $e->getMessage());
}
}
......@@ -220,16 +221,16 @@ class SupplierSyncController extends BaseSyncController
) {
try {
$this->updateCrmSupplier($existingSupplier, $data);
$this->syncResponse(0, 'CRM再次提交更新成功', ['supplier_id' => $existingSupplier['supplier_id']]);
return $this->syncResponse(0, 'CRM再次提交更新成功', ['supplier_id' => $existingSupplier['supplier_id']]);
LogService::AddLog($existingSupplier['supplier_id'], LogModel::UPDATE_OPERATE, 'CRM再次提交', 'CRM再次提交更新成功');
} catch (\Exception $e) {
Log::error('[CRM同步]再次提交更新失败: ' . $e->getMessage(), ['data' => $data]);
$this->syncResponse(-1, '更新失败: ' . $e->getTraceAsString());
return $this->syncResponse(-1, '更新失败: ' . $e->getTraceAsString());
}
}
Log::info('[CRM同步]供应商已存在且不满足再次提交条件,跳过: ' . $customerName);
$this->syncResponse(-1, '供应商已存在,跳过');
return $this->syncResponse(0, '供应商已存在,跳过');
}
try {
......@@ -380,10 +381,10 @@ class SupplierSyncController extends BaseSyncController
Log::info('[CRM同步]供应商创建成功', ['supplier_id' => $supplierId, 'supplier_name' => $customerName]);
$this->syncResponse(0, '同步成功', ['supplier_id' => $supplierId]);
return $this->syncResponse(0, '同步成功', ['supplier_id' => $supplierId]);
} catch (\Exception $e) {
Log::error('[CRM同步]创建供应商失败: ' . $e->getMessage(), ['data' => $data]);
$this->syncResponse(-1, '创建供应商失败: ' . $e->getMessage());
return $this->syncResponse(-1, '创建供应商失败: ' . $e->getMessage());
}
}
......@@ -499,7 +500,7 @@ class SupplierSyncController extends BaseSyncController
if ($validator->fails()) {
$error = $validator->errors()->first();
Log::warning('[CRM转让同步]参数校验失败: ' . $error, $data);
$this->syncResponse(-1, $error);
return $this->syncResponse(-1, $error);
}
$customerName = trim($data['customer_name']);
......@@ -510,7 +511,7 @@ class SupplierSyncController extends BaseSyncController
if (empty($supplier)) {
Log::warning('[CRM转让同步]供应商不存在或非CRM来源: ' . $customerName);
$this->syncResponse(-1, '供应商不存在或非CRM来源');
return $this->syncResponse(-1, '供应商不存在或非CRM来源');
}
$supplierId = $supplier['supplier_id'];
......@@ -536,10 +537,10 @@ class SupplierSyncController extends BaseSyncController
'transfer_saler' => $data['transfer_saler'],
]);
$this->syncResponse(0, '同步成功');
return $this->syncResponse(0, '同步成功');
} catch (\Exception $e) {
Log::error('[CRM转让同步]更新失败: ' . $e->getMessage(), ['data' => $data]);
$this->syncResponse(-1, '更新失败: ' . $e->getMessage());
return $this->syncResponse(-1, '更新失败: ' . $e->getMessage());
}
}
}
\ No newline at end of file
}
......@@ -145,7 +145,7 @@ class AuditCenterService
if ($result['code'] != 0) {
throw new Exception($result['msg']);
}
Log::info("---------------同步请求audit接口 {$route}-----audit返回结果-------------");
Log::info("---------------同步请求audit接口 {$route}-----audit返回结果-------------".\json_encode($result['data']));
return $result;
} catch (\Throwable $e) {
throw $e;
......
......@@ -6,6 +6,7 @@ namespace App\Http\Services;
use Carbon\Carbon;
use GuzzleHttp\Client;
use App\Model\LogModel;
use App\Model\SupplierLogModel;
use App\Model\RedisModel;
use App\Model\NationModel;
use App\Model\SkuUploadItem;
......@@ -15,19 +16,29 @@ use App\Model\IntracodeModel;
use App\Model\DepartmentModel;
use GuzzleHttp\RequestOptions;
use App\Model\SkuUploadLogModel;
use App\Model\SupplierSyncModel;
use App\Model\SupplierApplyModel;
use App\Model\SupplierMemoModel;
use App\Model\AttachmentAuditModel;
use App\Model\StandardBrandModel;
use App\Model\SupplierExtendModel;
use App\Model\SupplierPayTypeModel;
use App\Model\SupplierAddressModel;
use Illuminate\Support\Facades\DB;
use App\Model\SupplierAccountModel;
use App\Model\SupplierAddressModel;
use App\Model\SupplierChannelModel;
use App\Model\SupplierBlacklistModel;
use App\Model\SupplierContactModel;
use App\Model\SupplierShareApplyModel;
use App\Model\SupplierReceiptModel;
use App\Model\PurchaseRemarkModel;
use Illuminate\Support\Facades\Log;
use App\Model\SupplierContractModel;
use Maatwebsite\Excel\Facades\Excel;
use Illuminate\Support\Facades\Redis;
use App\Model\BigData\DataManageModel;
use App\Model\SupplierAttachmentsModel;
use App\Model\SupplierAttachmentModel;
use App\Model\StandardBrandMappingModel;
use App\Model\Purchase\PurchaseOrderModel;
use App\Http\Transformers\SupplierTransformer;
......@@ -2299,4 +2310,63 @@ class DataService
dump("已删除 {$count} 个京东采购员类型的联系人");
}
}
public function clearSupplierData($supplierId)
{
$supplierId = (int)$supplierId;
if ($supplierId <= 0) {
throw new \InvalidArgumentException('supplier_id不能为空');
}
$supplier = SupplierChannelModel::where('supplier_id', $supplierId)->first();
if (empty($supplier)) {
return [
'supplier_id' => $supplierId,
'deleted' => [],
'message' => '供应商不存在',
];
}
$supplierCode = $supplier->supplier_code;
$deleted = [];
DB::connection('web')->transaction(function () use ($supplierId, &$deleted) {
$deleteMap = [
'supplier_apply' => SupplierApplyModel::where('supplier_id', $supplierId),
'supplier_attachment_audit' => AttachmentAuditModel::where('supplier_id', $supplierId),
'supplier_attachments' => SupplierAttachmentsModel::where('supplier_id', $supplierId),
'supplier_contact' => SupplierContactModel::where('supplier_id', $supplierId),
'supplier_contract' => SupplierContractModel::where('supplier_id', $supplierId),
'supplier_extend' => SupplierExtendModel::where('supplier_id', $supplierId),
'supplier_memo' => SupplierMemoModel::where('supplier_id', $supplierId),
// 'supplier_pay_type' => SupplierPayTypeModel::where('supplier_id', $supplierId),
'supplier_receipt' => SupplierReceiptModel::where('supplier_id', $supplierId),
'supplier_share_apply' => SupplierShareApplyModel::where('supplier_id', $supplierId),
'supplier_sync' => SupplierSyncModel::where('supplier_id', $supplierId),
'supplier_address' => SupplierAddressModel::where('supplier_id', $supplierId),
'supplier_log' => SupplierLogModel::where('supplier_id', $supplierId),
'log' => LogModel::where('supplier_id', $supplierId),
'purchase_remark' => PurchaseRemarkModel::where('supplier_id', $supplierId),
];
foreach ($deleteMap as $table => $query) {
$deleted[$table] = $query->delete();
}
$deleted['supplier_channel'] = SupplierChannelModel::where('supplier_id', $supplierId)->delete();
});
$deleted['yunxin_account'] = SupplierAccountModel::where('supplier_id', $supplierId)->delete();
$redis = new RedisModel();
$redis->hdel('lie_supplier_info', $supplierId);
$redis->hdel('supplier_sku_upload_ruler_v2', $supplierId);
$redis->del('supplier_list_statistics_' . request()->user->userId);
return [
'supplier_id' => $supplierId,
'supplier_code' => $supplierCode,
'deleted' => $deleted,
];
}
}
......@@ -104,6 +104,11 @@ Route::group(['middleware' => ['external'], 'namespace' => 'Sync'], function ()
});
Route::match(['get', 'post'], '/test', function () {
$result = CrmService::getSignCompanyList();
$isAdmin = request()->user->userId == 1000 ? true : false;
if (!$isAdmin) {
return response()->json(['code' => 403, 'msg' => '无权限']);
}
$supplierId = (int)request()->get('supplier_id');
$result = (new DataService())->clearSupplierData($supplierId);
return response()->json($result);
});
......@@ -10,8 +10,8 @@
<div class="split-group" style="height: 170px;">
<div class="split-item" id="s1" style="text-align: center">
<div class="layui-row">
<a class="main_filter layui-badge layui-bg-green" title='全部' id="total">全部</a>
{{-- <div class="layui-row">
<a class="main_filter layui-badge layui-bg-green" id="total">全部</a>
<div class="layui-row">
<a class="main_filter" title="待复审" id="need_review">
待复审
</a>
......@@ -21,10 +21,12 @@
<div class="split-item" id="s6" style="text-align: center">
<div class="layui-row">
<a class="main_filter" title="战略供应商" id="level_a">
战略供应商
</a>
</div>
<div class="layui-row">
<a class="main_filter" title="账期供应商" id="pay_type_term">
账期供应商
</a>
</div>
<div class="layui-row">
......@@ -38,10 +40,11 @@
</a>
</div>
@if(checkPerm('SupplierBlockList'))
<div class="layui-row">
<a class="main_filter" id="block" data-value="-3">
</a>
</div>
<div class="layui-row">
<a class="main_filter" id="block" data-value="-3">
黑名单
</a>
</div>
@endif
</div>
<div class="split-item" id="s7" style="text-align: center">
......
......@@ -10,8 +10,8 @@
<div class="split-group" style="height: 170px;">
<div class="split-item" id="s1" style="text-align: center">
<div class="layui-row">
<a class="main_filter layui-badge layui-bg-green" title='全部' id="total">全部</a>
<?php /* <div class="layui-row">
<a class="main_filter layui-badge layui-bg-green" id="total">全部</a>
<div class="layui-row">
<a class="main_filter" title="待复审" id="need_review">
待复审
</a>
......@@ -21,10 +21,12 @@
<div class="split-item" id="s6" style="text-align: center">
<div class="layui-row">
<a class="main_filter" title="战略供应商" id="level_a">
战略供应商
</a>
</div>
<div class="layui-row">
<a class="main_filter" title="账期供应商" id="pay_type_term">
账期供应商
</a>
</div>
<div class="layui-row">
......@@ -38,10 +40,11 @@
</a>
</div>
<?php if(checkPerm('SupplierBlockList')): ?>
<div class="layui-row">
<a class="main_filter" id="block" data-value="-3">
</a>
</div>
<div class="layui-row">
<a class="main_filter" id="block" data-value="-3">
黑名单
</a>
</div>
<?php endif; ?>
</div>
<div class="split-item" id="s7" style="text-align: center">
......@@ -296,18 +299,18 @@
<?php $statusPresenter = app('App\Presenters\StatusPresenter'); ?>
<?php echo $statusPresenter->render('supplier_source', '供应商来源', 0, config('fixed.SupplierSource')); ?>
</div>
<div class="layui-inline">
<label class="layui-form-label">代理品牌</label>
<div class="layui-input-inline">
<div id="agency_brands_filter" style="width: 425px"></div>
<input type="hidden" name="agency_brands" id="agency_brands_filter_value" value="">
</div>
</div>
<div class="layui-row">
<div class="layui-inline" style="width: 600px">
<?php $transformableTimeIntervalPresenter = app('App\Presenters\Filter\TransformableTimeIntervalPresenter'); ?>
<?php echo $transformableTimeIntervalPresenter->render(['update_time'=>'更新时间','create_time'=>'创建时间','sku_create_time' => '首次上传sku时间']); ?>
<div class="layui-inline">
<label class="layui-form-label">代理品牌</label>
<div class="layui-input-inline">
<div id="agency_brands_filter" style="width: 425px"></div>
<input type="hidden" name="agency_brands" id="agency_brands_filter_value" value="">
</div>
</div>
<div class="layui-row">
<div class="layui-inline" style="width: 600px">
<?php $transformableTimeIntervalPresenter = app('App\Presenters\Filter\TransformableTimeIntervalPresenter'); ?>
<?php echo $transformableTimeIntervalPresenter->render(['update_time'=>'更新时间','create_time'=>'创建时间','sku_create_time' => '首次上传sku时间']); ?>
</div>
......
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