Commit 3b46af89 by 杨树贤

pdf包更新

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