Commit 076d0c01 by mushishixian

标签系统对接

parent 7ffee9ed
......@@ -191,6 +191,11 @@ class SupplierFilter
$query->where('status', '!=', SupplierChannelModel::STATUS_DISABLE)
->where('purchase_uid', '');
break;
case "no_channel_uid":
//没有渠道开发
$query->where('status', '!=', SupplierChannelModel::STATUS_DISABLE)
->where('channel_uid', '');
break;
case "invalid_channel_uid":
//不合理的渠道开发(比如渠道开发离职了)
$adminUserService = new AdminUserService();
......
......@@ -160,8 +160,6 @@ class SupplierController extends Controller
if (empty($supplier)) {
return '供应商不存在';
}
$tagService = new SupplierTagService();
$supplier['system_tags'] = implode(',',$tagService->getSystemTagsBySupplierId($supplierId));
//省市id,给控件用
$this->data['province_city'] = [$supplier['province_id'], $supplier['city_id']];
$this->data['supplier'] = $supplier;
......
......@@ -141,16 +141,17 @@ class SupplierService
$this->saveSkuUploadRulerToRedis($supplierId, $channel['sku_upload_ruler']);
//判断是否要移出待跟进
$this->updateIsFollowUp($supplierId);
//保存标签到标签系统
$oldCustomerTags = array_get($oldSupplier, 'customer_tags');
$oldSystemTags = array_get($oldSupplier, 'system_tags');
$tagService = new SupplierTagService();
$tagService->saveTags($supplierId, 14, $channel['system_tags'], $oldSystemTags);
$tagService->saveTags($supplierId, 4, $channel['customer_tags'], $oldCustomerTags);
}
//保存生成的内部编码
$this->saveSupplierCode($supplierId);
//重新生成外部显示的编码
$this->generateSupplierSn($supplierId, $channel['supplier_group']);
$oldSystemTags = array_get($oldSupplier, 'system_tags');
$oldCustomerTags = array_get($oldSupplier, 'customer_tags');
//保存标签到标签系统
$tagService = new SupplierTagService();
$tagService->saveSystemTag($supplierId, $channel['system_tags'], $oldSystemTags);
return true;
});
......@@ -205,6 +206,14 @@ class SupplierService
unset($channel['purchase_uid']);
}
if (!empty($channel['system_tags'])) {
$channel['system_tags'] = rtrim($channel['system_tags'], ',');
}
if (!empty($channel['customer_tags'])) {
$channel['customer_tags'] = rtrim($channel['customer_tags'], ',');
}
$channel['cn_ratio'] = empty($channel['cn_ratio']) ? 1 : $channel['cn_ratio'];
$channel['us_ratio'] = empty($channel['us_ratio']) ? 1 : $channel['us_ratio'];
......@@ -214,6 +223,7 @@ class SupplierService
unset($channel['upload_file']);
$channel['established_time'] = strtotime($channel['established_time']);
//省市选择的处理
if (!empty($channel['province_city'])) {
$regionData = explode(',', $channel['province_city']);
......
......@@ -7,6 +7,7 @@ namespace App\Http\Services;
use GuzzleHttp\Client;
use GuzzleHttp\RequestOptions;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
class SupplierTagService
{
......@@ -46,27 +47,27 @@ class SupplierTagService
}
//新增/修改标签和供应商id对应关系到标签系统
public function saveSystemTag($supplierId, $newSystemTags, $oldSystemTags)
public function saveTags($supplierId, $tagUse, $newTags, $oldTags)
{
$newSystemTags = explode(',', $newSystemTags);
$oldSystemTags = explode(',', $oldSystemTags);
$newTags = explode(',', $newTags);
$oldTags = explode(',', $oldTags);
//先区分哪些需要删除,哪些需要修改
$allSystemTags = array_merge($newSystemTags, $oldSystemTags);
$allSystemTags = array_merge($newTags, $oldTags);
$deleteTags = [];
$keepTags = [];
foreach ($allSystemTags as $tag) {
//在新标签,不在老标签,就是新增,否则就是删除
if (in_array($tag, $newSystemTags) && !in_array($tag, $oldSystemTags)) {
if (in_array($tag, $newTags) && !in_array($tag, $oldTags)) {
$keepTags[] = $tag;
}
if (!in_array($tag, $newSystemTags) && in_array($tag, $oldSystemTags)) {
if (!in_array($tag, $newTags) && in_array($tag, $oldTags)) {
$deleteTags[] = $tag;
}
}
$params = [];
foreach ($deleteTags as $tag) {
$params[$tag] = [
'tag_use' => 14,
'tag_use' => $tagUse,
'business' => 5,
'modifier' => 1000,
'modifier_name' => 'admin',
......@@ -81,7 +82,7 @@ class SupplierTagService
foreach ($keepTags as $tag) {
$params[$tag] = [
'tag_use' => 14,
'tag_use' => $tagUse,
'business' => 5,
'modifier' => 1000,
'modifier_name' => 'admin',
......@@ -97,7 +98,10 @@ class SupplierTagService
RequestOptions::JSON => $params,
]);
$data = json_decode($response->getBody()->getContents(), true);
dd($data);
dd(json_encode($params));
if (!empty($data['status']) && $data['status'] == 1) {
return true;
} else {
Log::error('保存标签失败,' . json_encode($data));
}
}
}
\ No newline at end of file
......@@ -44,5 +44,7 @@ return [
'return_address' => '退货地址',
'return_phone' => '退货收货人电话 ',
'return_consignee' => '退货收货人',
'system_tags' => '系统标签',
'customer_tags' => '自定义标签',
]
];
\ No newline at end of file
......@@ -18,6 +18,7 @@ layui.config({ // common.js是配置layui扩展模块的目录,每个页面
zTree: 'zTree/zTree',
xmSelect: 'xmSelect',
selectN: 'selectExt/layui_extends/selectN',
// selectN: 'selectExt/layui_extends/selectN',
}).use(['layer', 'admin'], function () {
var $ = layui.jquery;
var layer = layui.layer;
......
<script>
layui.use(['table', 'form', 'element', 'layer', 'admin', 'upload', 'index'], function () {
let table = layui.table;
let layer = layui.layer;
let form = layui.form;
let index = layui.index;
let admin = layui.admin;
let element = layui.element;
let upload = layui.upload;
let supplierId = getQueryVariable('supplier_id')
$('#updateSupplierUrl').click(function () {
......
<script>
layui.use(['table', 'form', 'element', 'layer', 'admin', 'laydate', 'xmSelect', 'selectN'], function () {
layui.use(['table', 'form', 'element', 'layer', 'admin', 'laydate', 'xmSelect', 'selectN','tagsInput'], function () {
let admin = layui.admin;
let form = layui.form;
let selectN = layui.selectN;
......@@ -13,9 +13,11 @@
, format: 'yyyy-MM'
});
const supplierId = getQueryVariable('supplier_id');
$("#supplier_name").blur(function () {
const supplier_name = $(this).val();
const supplier_id = getQueryVariable("supplier_id");
const supplier_id = supplierId;
$('#supplier_check_tip').remove();
let url = '/api/supplier/CheckSupplierName?supplier_name=' + supplier_name + '&supplier_id=' + supplier_id;
let res = ajax(url);
......@@ -130,10 +132,15 @@
};
}
let systemTagOption = getTagOption('system_tags_selector', 2);
let tagSelector = xmSelect.render(systemTagOption);
let tagIds = $('#system_tags').attr('value');
tagSelector.setValue(tagIds.split(','));
if (supplierId) {
let systemTagOption = getTagOption('system_tags_selector', 2);
let tagSelector = xmSelect.render(systemTagOption);
let tagIds = $('#system_tags').attr('value');
tagSelector.setValue(tagIds.split(','));
//自定义标签
$('#customer_tags').tagsInput({});
}
let regionData = {!! json_encode($region_data) !!};
let provinceCity = {!! !empty($province_city)?json_encode($province_city):'[]' !!};
......
......@@ -178,6 +178,32 @@
</div>
<hr/>
<blockquote class="layui-elem-quote layui-text">
<b>供应商标签</b>
</blockquote>
<div class="layui-row">
<div class="layui-col-md12">
系统标签 :
@foreach (explode(',',$supplier['system_tags']) as $tag)
@if (empty($tag))
暂无
@continue
@endif
<span class="layui-btn layui-btn-xs">{{$tag}}</span>
@endforeach
</div>
<div class="layui-col-md12">
自定义标签 :
@foreach (explode(',',$supplier['customer_tags']) as $tag)
@if (empty($tag))
暂无
@continue
@endif
<span class="layui-btn layui-btn-xs">{{$tag}}</span>
@endforeach
</div>
</div>
<hr/>
<blockquote class="layui-elem-quote layui-text">
<b>财务信息</b>
</blockquote>
@include('web.supplier.SupplierReceipt')
......
......@@ -161,7 +161,7 @@
</blockquote>
<div class="layui-form-item">
<label class="layui-form-label">
系统标签</label>
系统标签 : </label>
<div class="layui-input-block" style="margin-top: 15px">
<div id="system_tags_selector" class="layui-input-inline" style="width: 100%;">
</div>
......@@ -169,6 +169,13 @@
id="system_tags">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">
自定义标签 : </label>
<div class="layui-input-block" style="margin-top: 15px">
<input name="customer_tags" id="customer_tags" value="{{$supplier['customer_tags'] or ''}}">
</div>
</div>
@endif
@if($operate=='add')
......
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