Commit b92aef04 by mushishixian

标签修改

parent f9cee5bc
......@@ -7,6 +7,7 @@ use App\Http\Services\RegionService;
use App\Http\Services\SupplierAttachmentService;
use App\Http\Services\SupplierService;
use App\Http\Services\SupplierStatisticsService;
use App\Http\Services\SupplierTagService;
use App\Http\Transformers\LogTransformer;
use App\Http\Transformers\SupplierTransformer;
use App\Model\IntracodeModel;
......@@ -165,6 +166,12 @@ class SupplierController extends Controller
}
//省市id,给控件用
$this->data['province_city'] = [$supplier['province_id'], $supplier['city_id']];
//获取标签情况
$tagService = new SupplierTagService();
$systemTags = $tagService->getTagsBySupplierId($supplierId, 1);
$customerTags = $tagService->getTagsBySupplierId($supplierId, 2);
$supplier['system_tags'] = $systemTags ? implode(',', $systemTags) : '';
$supplier['customer_tags'] = $customerTags ? implode(',', $customerTags) : '';
$this->data['supplier'] = $supplier;
$this->data['address'] = $supplierService->getAddress($supplierId);
$supplierAttachmentService = new SupplierAttachmentService();
......
......@@ -150,8 +150,8 @@ class SupplierService
$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);
// $tagService->saveTags($supplierId, 14, $channel['system_tags'], $oldSystemTags);
// $tagService->saveTags($supplierId, 4, $channel['customer_tags'], $oldCustomerTags);
}
//保存附件
$attachmentService = new SupplierAttachmentService();
......
......@@ -29,6 +29,9 @@ class SupplierTagService
$data = !empty($data['data']) ? $data['data'] : [];
$result = [];
foreach ($data as $key => $value) {
if (empty($value)) {
continue;
}
$result[] = [
'tag_id' => $value,
'tag_name' => $value,
......@@ -38,22 +41,15 @@ class SupplierTagService
}
//获取供应商对应的标签
public function getSystemTagsBySupplierId($supplierId)
public function getTagsBySupplierId($supplierId, $type = 1)
{
// $supplierId = 1;
$response = $this->client->get('/get?tag_use=14&req_id=' . $supplierId);
//1是系统标签,2是自定义标签
$tagUse = $type == 1 ? 14 : 4;
$response = $this->client->get('/get?tag_use=' . $tagUse . '&req_id=' . $supplierId);
$data = json_decode($response->getBody()->getContents(), true);
return !empty($data['data']) ? $data['data'] : [];
}
//获取供应商对应的自定义标签
public function getCustomerTagsBySupplierId($supplierId)
{
// $supplierId = 1;
$response = $this->client->get('/get?tag_use=4&req_id=' . $supplierId);
$data = json_decode($response->getBody()->getContents(), true);
return !empty($data['data']) ? $data['data'] : [];
}
//新增/修改标签和供应商id对应关系到标签系统
public function saveTags($supplierId, $tagUse, $newTags, $oldTags)
......@@ -85,7 +81,7 @@ class SupplierTagService
'modifier_name' => 'admin',
'data' => [
[
'id' => (int)$supplierId,
'id' => $supplierId,
'tag_status' => 0,
]
]
......@@ -114,9 +110,6 @@ class SupplierTagService
RequestOptions::JSON => $params,
]);
$data = json_decode($response->getBody()->getContents(), true);
// if ($tagUse==4) {
// dd($params,$data);
// }
if (!empty($data['status']) && $data['status'] == 1) {
return true;
} else {
......
......@@ -46,8 +46,4 @@ Route::match(['get', 'post'], '/test', function () {
$service = new \App\Http\Services\DataService();
// $service->initSystemTag();
// $service->transferFileData();
$tagService = new \App\Http\Services\SupplierTagService();
// $res = $tagService->getSystemTagsBySupplierId(12293);
$res = $tagService->getCustomerTagsBySupplierId(12293);
dd($res);
});
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