Commit 076d0c01 by mushishixian

标签系统对接

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