Commit 3b46af89 by 杨树贤

pdf包更新

parent 79bc9cea
......@@ -26,11 +26,16 @@ class StandardBrandService
if (!empty($searchBrandName)) {
$brandIds = SpuBrandModel::where('brand_name', 'like', "%$searchBrandName%")->limit(100)->pluck('brand_id');
if (!empty($brandIds)) {
$standardBrandIds = StandardBrandMappingModel::whereIn('brand_id',
$brandIds)->pluck('standard_brand_id');
$standardBrandIds = StandardBrandMappingModel::whereIn(
'brand_id',
$brandIds
)->pluck('standard_brand_id');
if (!empty($standardBrandIds)) {
$query->whereIn('standard_brand_id', $standardBrandIds)->orWhere('brand_name', 'like',
"%$searchBrandName%")->orderByRaw("CASE WHEN brand_name LIKE '${searchBrandName}' THEN 1 WHEN brand_name LIKE '${searchBrandName}%' THEN 2 WHEN brand_name LIKE '%${searchBrandName}' THEN 4 ELSE 3 END");
$query->whereIn('standard_brand_id', $standardBrandIds)->orWhere(
'brand_name',
'like',
"%$searchBrandName%"
)->orderByRaw("CASE WHEN brand_name LIKE '${searchBrandName}' THEN 1 WHEN brand_name LIKE '${searchBrandName}%' THEN 2 WHEN brand_name LIKE '%${searchBrandName}' THEN 4 ELSE 3 END");
$flag = true;
}
}
......@@ -39,10 +44,15 @@ class StandardBrandService
//如果有根据普通品牌搜出标准品牌,那么还要补充数据显示
if ($flag) {
$list['data'] = array_map(function ($value) use ($searchBrandName) {
$brandIds = StandardBrandMappingModel::where('standard_brand_id',
$value['brand_id'])->pluck('brand_id')->toArray();
$brandNames = SpuBrandModel::whereIn('brand_id', $brandIds)->where('brand_name', 'like',
"%${searchBrandName}%")->limit(10)->pluck('brand_name')->toArray();
$brandIds = StandardBrandMappingModel::where(
'standard_brand_id',
$value['brand_id']
)->pluck('brand_id')->toArray();
$brandNames = SpuBrandModel::whereIn('brand_id', $brandIds)->where(
'brand_name',
'like',
"%${searchBrandName}%"
)->limit(10)->pluck('brand_name')->toArray();
//去除原始数据那些换行或者tab符号,原始数据是很乱的
$brandNames = array_map(function ($value) {
return $value ? str_replace("\t", '', $value) : $value;
......@@ -95,7 +105,7 @@ class StandardBrandService
{
$standardBrandNames = explode(',', trim($standardBrandNames, ','));
$standardBrandIds = StandardBrandModel::whereIn('brand_name', $standardBrandNames)->pluck('standard_brand_id')->toArray();
return $this->getBrandInitValue(implode(',',$standardBrandIds));
return $this->getBrandInitValue(implode(',', $standardBrandIds));
}
//根据品牌id获取标准品牌名字列表
......@@ -118,8 +128,10 @@ class StandardBrandService
public function checkStandardBrandNameList($standardBrandNameList = [])
{
//去数据库查询
$validStandardBrandList =StandardBrandModel::whereIn('brand_name',
$standardBrandNameList)
$validStandardBrandList = StandardBrandModel::whereIn(
'brand_name',
$standardBrandNameList
)
->pluck('brand_name', 'standard_brand_id')->toArray();
$validStandardBrandMap = array_flip($validStandardBrandList);
$invalidBrandNameList = [];
......@@ -161,4 +173,4 @@ class StandardBrandService
'valid_brand_ids' => $validStandardBrandIds,
];
}
}
\ No newline at end of file
}
......@@ -29,8 +29,10 @@ class SupplierContactService
'can_check_uids' => request()->user->userId,
];
$contactData = array_filter($contactData, function ($contact) {
if (empty($contact['supplier_consignee']) && empty($contact['supplier_telephone'])
&& empty($contact['supplier_mobile'])) {
if (
empty($contact['supplier_consignee']) && empty($contact['supplier_telephone'])
&& empty($contact['supplier_mobile'])
) {
return false;
}
return true;
......@@ -70,7 +72,6 @@ class SupplierContactService
$result = $model->insertGetId($contact);
$contactId = $result;
}
}
//找出所有的联系人对应的采购id,更新主表
$canCheckUids = $model->where('supplier_id', $supplierId)->pluck('can_check_uids');
......@@ -175,8 +176,10 @@ class SupplierContactService
$contact['admin_id'] = request()->user->userId;
$result = $contactModel->insert($contact);
if ($result) {
$channelUids = $contacts = $contactModel->where('supplier_id',
$supplierId)->pluck('can_check_uids')->toArray();
$channelUids = $contacts = $contactModel->where(
'supplier_id',
$supplierId
)->pluck('can_check_uids')->toArray();
$supplierModel = new SupplierChannelModel();
$result = $supplierModel->where('supplier_id', $supplierId)->update([
'channel_uid' => implode(',', $channelUids),
......@@ -192,5 +195,4 @@ class SupplierContactService
}
return $result;
}
}
\ No newline at end of file
}
This diff could not be displayed because it is too large.
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