Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
杨树贤
/
liexin_supplier
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
65ee9685
authored
Jul 26, 2021
by
mushishixian
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
标准品牌
parent
175ec29f
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
79 additions
and
6 deletions
app/Http/Controllers/Api/CommonApiController.php
app/Http/Services/DataService.php
app/Http/Transformers/SupplierTransformer.php
app/Http/Validators/SupplierValidator.php
app/Http/routes.php
app/Model/BrandModel.php
app/Model/StandardBrandModel.php
resources/views/script/SupplierListScript.blade.php
resources/views/script/supplier/SupplierBaseScript.blade.php
resources/views/web/supplier/SupplierBase.blade.php
resources/views/web/supplier/SupplierFile.blade.php
app/Http/Controllers/Api/CommonApiController.php
View file @
65ee9685
...
...
@@ -37,6 +37,14 @@ class CommonApiController extends Controller
return
$this
->
response
(
0
,
'ok'
,
$brandList
);
}
//获取标准品牌
public
function
getStandardBrandList
(
$request
)
{
$model
=
new
BrandModel
();
$brandList
=
$model
->
getStandardBrandList
();
return
$this
->
response
(
0
,
'ok'
,
$brandList
);
}
private
function
SearchBrand
(
$request
)
{
$brandName
=
$request
->
input
(
'brand_name'
);
...
...
app/Http/Services/DataService.php
View file @
65ee9685
...
...
@@ -14,6 +14,7 @@ use App\Model\SupplierContactModel;
use
GuzzleHttp\Client
;
use
GuzzleHttp\RequestOptions
;
use
Illuminate\Support\Facades\Log
;
use
Illuminate\Support\Facades\Redis
;
use
Maatwebsite\Excel\Facades\Excel
;
//这个服务是处理数据的,比如导出信息,或者临时修复数据,所以代码会比较多
...
...
@@ -129,6 +130,35 @@ class DataService
}
}
//替换老的品牌选择成为新的标准品牌id
public
function
replaceStandardBrandId
()
{
$supplierModel
=
new
SupplierChannelModel
();
$suppliers
=
$supplierModel
->
where
(
'main_brands'
,
'!='
,
''
)
->
get
()
->
toArray
();
$redis
=
new
RedisModel
();
foreach
(
$suppliers
as
$supplier
)
{
$mainBrands
=
explode
(
','
,
$supplier
[
'main_brands'
]);
$standardBrandIds
=
[];
foreach
(
$mainBrands
as
$brandId
)
{
//找标准品牌ID,没有直接跳过
$standardBrandId
=
$redis
->
hget
(
'standard_brand_mapping'
,
$brandId
);
if
(
empty
(
$standardBrandId
))
{
continue
;
}
$standardBrandIds
[]
=
$standardBrandId
;
}
if
(
!
empty
(
$standardBrandIds
))
{
$standardBrandIdsStr
=
implode
(
','
,
$standardBrandIds
);
}
else
{
$standardBrandIdsStr
=
''
;
}
// $supplierModel->where('supplier_id', $supplier['supplier_id'])->update([
// 'main_brands' => $standardBrandIdsStr
// ]);
print_r
(
$standardBrandIds
);
}
}
}
app/Http/Transformers/SupplierTransformer.php
View file @
65ee9685
...
...
@@ -36,6 +36,7 @@ class SupplierTransformer
$supplier
[
'channel_username'
]
=
$this
->
getChannelUserNames
(
$supplier
[
'channel_uid'
]);
$supplier
[
'purchase_username'
]
=
array_get
(
$users
,
$supplier
[
'purchase_uid'
]);
$supplier
[
'status_name'
]
=
array_get
(
config
(
'fixed.SupplierStatus'
),
$supplier
[
'status'
]);
$supplier
[
'region_name'
]
=
array_get
(
config
(
'fixed.Region'
),
$supplier
[
'region'
],
'暂无'
);
$supplier
[
'contact_num'
]
=
$this
->
getContactNum
(
$supplier
[
'supplier_id'
]);
$supplier
[
'has_sku'
]
=
$supplier
[
'sku_num'
]
?
'是'
:
'否'
;
$supplier
[
'is_own'
]
=
$supplier
[
'create_uid'
]
==
request
()
->
user
->
userId
?
"创建"
:
"指派"
;
...
...
app/Http/Validators/SupplierValidator.php
View file @
65ee9685
...
...
@@ -20,7 +20,8 @@ class SupplierValidator
'supplier_name'
=>
'required'
,
'legal_representative'
=>
'required'
,
'stockup_type'
=>
'required'
,
'supplier_address'
=>
'required'
,
'main_brands'
=>
'required'
,
// 'supplier_address' => 'required',
'region'
=>
'required'
,
'cn_delivery_time'
=>
'regex:/^\d+\-\d$/'
,
'us_delivery_time'
=>
'regex:/^\d+\-\d$/'
,
...
...
@@ -118,6 +119,7 @@ class SupplierValidator
'return_address.max'
=>
'退货地址不能超过100个字符'
,
'return_consignee.max'
=>
'退货收货人不能超过50个字符'
,
'return_phone.max'
=>
'退货收货人电话不能超过50个字符'
,
'main_brands.require'
=>
'主营品牌不能为空'
,
];
}
...
...
app/Http/routes.php
View file @
65ee9685
...
...
@@ -42,5 +42,6 @@ Route::group(['middleware' => ['web'], 'namespace' => 'Api'], function () {
});
Route
::
match
([
'get'
,
'post'
],
'/test'
,
function
()
{
$service
=
new
\App\Http\Services\DataService
();
$service
->
initSystemTag
();
// $service->initSystemTag();
$service
->
replaceStandardBrandId
();
});
app/Model/BrandModel.php
View file @
65ee9685
...
...
@@ -63,4 +63,19 @@ class BrandModel extends Model
}
return
$brandList
;
}
public
function
getStandardBrandList
()
{
$redis
=
new
RedisModel
();
$standardBrands
=
json_decode
(
$redis
->
get
(
'standard_brands_for_supplier'
),
true
);
if
(
empty
(
$standardBrands
))
{
$standardBrandModel
=
new
StandardBrandModel
();
$standardBrands
=
$standardBrandModel
->
selectRaw
(
'brand_name,standard_brand_id as brand_id'
)
->
where
(
'status'
,
1
)
->
get
()
->
toArray
();
$redis
->
set
(
'standard_brands_for_supplier'
,
json_encode
(
$standardBrands
));
$redis
->
expire
(
'standard_brands_for_supplier'
,
600
);
}
return
$standardBrands
;
}
}
\ No newline at end of file
app/Model/StandardBrandModel.php
0 → 100644
View file @
65ee9685
<?php
namespace
App\Model
;
use
Illuminate\Database\Eloquent\Model
;
class
StandardBrandModel
extends
Model
{
protected
$connection
=
'spu'
;
protected
$table
=
'brand_standard'
;
public
$timestamps
=
false
;
}
resources/views/script/SupplierListScript.blade.php
View file @
65ee9685
...
...
@@ -75,6 +75,7 @@
}
},
{
field
:
'supplier_group'
,
title
:
'供应商性质'
,
align
:
'center'
,
width
:
115
},
{
field
:
'region_name'
,
title
:
'区域'
,
align
:
'center'
,
width
:
60
},
{
field
:
'stockup_type'
,
title
:
'合作类型'
,
align
:
'center'
,
width
:
120
,
templet
:
function
(
data
)
{
return
"
<
span
title
=
'" + data.stockup_type + "'
>
" + data.stockup_type + "
<
/span>
"
...
...
@@ -103,7 +104,6 @@
{
field
:
'purchase_username'
,
title
:
'渠道开发员'
,
align
:
'center'
,
width
:
110
},
{
field
:
'create_name'
,
title
:
'创建人'
,
align
:
'center'
,
width
:
70
},
{
field
:
'update_time'
,
title
:
'最近修改时间'
,
align
:
'center'
,
width
:
145
},
{
field
:
'create_time'
,
title
:
'创建时间'
,
align
:
'center'
,
width
:
145
},
];
@
if
(
checkPerm
(
'ViewFakeSupplier'
))
...
...
@@ -113,7 +113,9 @@
}
})
@
endif
cols
.
push
(
{
field
:
'create_time'
,
title
:
'创建时间'
,
align
:
'center'
,
width
:
145
},
);
table
.
render
({
elem
:
'#list'
,
url
:
'/api/supplier/GetSupplierList'
...
...
resources/views/script/supplier/SupplierBaseScript.blade.php
View file @
65ee9685
...
...
@@ -66,7 +66,7 @@
//渲染主营品牌的多选
function
getBrandOption
(
element
,
brandType
)
{
let
brandUrl
=
'/api/common/get
BrandList?type='
+
brandType
;
let
brandUrl
=
'/api/common/get
StandardBrandList'
;
let
brandRes
=
ajax
(
brandUrl
);
let
brandList
=
brandRes
.
data
;
return
{
...
...
resources/views/web/supplier/SupplierBase.blade.php
View file @
65ee9685
...
...
@@ -101,6 +101,7 @@
</div>
<div
class=
"layui-form-item"
>
<label
class=
"layui-form-label"
>
<span
class=
"require"
>
*
</span>
主营品牌
</label>
<div
class=
"layui-input-block"
style=
"margin-top: 15px"
>
<div
id=
"brand_selector"
class=
"layui-input-inline"
style=
"width: 100%;"
>
...
...
resources/views/web/supplier/SupplierFile.blade.php
View file @
65ee9685
...
...
@@ -23,7 +23,7 @@
</button>
<input
type=
"hidden"
class=
"upload_obj"
value=
""
>
</div>
<div
class=
"layui-col-md12"
style=
"padding-left:
35px;margin-top: 20
px"
>
<div
class=
"layui-col-md12"
style=
"padding-left:
45px;margin-top: 5
px"
>
<blockquote
class=
"layui-elem-quote layui-quote-nm"
style=
"padding-bottom: 5px"
>
<div
id=
"file_list"
class=
"layui-row"
>
@foreach(config('fixed.FileNameMapping') as $name=>$cnName)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment