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
650bf243
authored
Aug 12, 2021
by
mushishixian
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
精选
parent
f007a769
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
58 additions
and
14 deletions
app/Http/Controllers/Api/SkuApiController.php
app/Http/Controllers/Filter/SkuListFilter.php
app/Http/Services/SkuService.php
resources/views/script/SkuListScript.blade.php
resources/views/web/sku/SkuListCommon.blade.php
app/Http/Controllers/Api/SkuApiController.php
View file @
650bf243
...
...
@@ -97,7 +97,8 @@ class SkuApiController extends Controller
$this
->
response
(
-
1
,
'请选择要操作的SKU'
,
'0'
);
}
$skuService
=
new
SkuService
();
if
(
$result
[
'errcode'
]
==
0
)
{
$result
=
$skuService
->
setPreferSku
(
$skuIds
,
$prefer
);
if
(
$result
)
{
$this
->
response
(
0
,
'操作成功'
);
}
else
{
$this
->
response
(
-
1
,
'操作失败,原因是 : '
.
$result
[
'errmsg'
]);
...
...
app/Http/Controllers/Filter/SkuListFilter.php
View file @
650bf243
...
...
@@ -13,7 +13,7 @@ class SkuListFilter
public
function
listFilter
()
{
$map
=
request
()
->
all
();
//dd($map);
//只获取专卖的数据
$map
[
'supplier_id'
]
=
17
;
if
((
!
empty
(
$map
[
'create_time'
])))
{
...
...
@@ -66,7 +66,6 @@ class SkuListFilter
unset
(
$map
[
$k
]);
}
}
$map
[
'p'
]
=
$map
[
'page'
];
unset
(
$map
[
'page'
]);
...
...
app/Http/Services/SkuService.php
View file @
650bf243
...
...
@@ -68,6 +68,12 @@ class SkuService
}
$sku
[
'cn_price'
]
=
array_get
(
$moqPrice
,
'price_cn'
);
$sku
[
'us_price'
]
=
array_get
(
$moqPrice
,
'price_us'
);
//获取是否精选和标签
$goodsTag
=
$this
->
getGoodsTag
(
$sku
[
'goods_id'
]);
$sku
[
'goods_label'
]
=
array_get
(
$goodsTag
,
'goods_label'
,
''
);
$sku
[
'goods_label_name'
]
=
array_get
(
config
(
'field.SkuGoodsLabel'
),
$sku
[
'goods_label'
],
''
);
$sku
[
'tags'
]
=
array_get
(
$goodsTag
,
'tags'
,
[]);
$sku
[
'is_prefer'
]
=
in_array
(
1
,
$sku
[
'tags'
])
?
1
:
0
;
$list
[]
=
$sku
;
}
$intracodeModel
=
new
IntracodeModel
();
...
...
@@ -87,22 +93,47 @@ class SkuService
];
}
//设置精选
public
function
setPreferSku
(
$skuIds
,
$prefer
)
{
//直接操作redis的goods_tag,然后推送es的修改任务即可
$redis
=
new
RedisModel
();
foreach
(
$skuIds
as
$skuId
)
{
$goodsTag
=
$redis
->
hget
(
'goods_tag'
,
$skuId
);
if
(
!
empty
(
$goodsTag
[
'tags'
]))
{
$tag
=
json_decode
(
$goodsTag
[
'tag'
],
true
);
$goodsTag
=
json_decode
(
$goodsTag
,
true
);
if
(
!
empty
(
$goodsTag
))
{
$tag
=
$goodsTag
[
'tags'
];
//判断是否有精选标签(1),而且操作是取消精选
if
(
in_array
(
1
,
$tag
)
&&
$prefer
==
-
1
)
{
$key
=
array_search
(
1
,
$tag
);
if
(
!
empty
(
$key
))
{
unset
(
$goodsTag
[
'tag'
][
$key
]);
if
(
$prefer
==
-
1
)
{
if
(
in_array
(
1
,
$tag
))
{
$key
=
array_search
(
1
,
$tag
);
if
(
$key
!==
false
)
{
unset
(
$goodsTag
[
'tags'
][
$key
]);
}
}
}
else
{
if
(
!
in_array
(
1
,
$tag
))
{
$tag
[]
=
1
;
$goodsTag
[
'tags'
]
=
$tag
;
}
}
$result
=
$redis
->
hset
(
'goods_tag'
,
$skuId
,
json_encode
(
$goodsTag
));
}
else
{
//没有直接跳过
continue
;
}
if
(
$result
===
false
)
{
return
false
;
}
$redis
->
lpush
(
'update_list_sku'
,
$skuId
);
}
return
true
;
}
private
function
getGoodsTag
(
$skuId
)
{
$redis
=
new
RedisModel
();
$result
=
$redis
->
hget
(
'goods_tag'
,
$skuId
);
return
$result
?
json_decode
(
$result
,
true
)
:
[];
}
}
\ No newline at end of file
resources/views/script/SkuListScript.blade.php
View file @
650bf243
...
...
@@ -41,6 +41,7 @@
field
:
'brand_name'
,
title
:
'品牌'
,
align
:
'center'
,
width
:
120
},
{
field
:
'encap'
,
title
:
'封装'
,
align
:
'center'
,
width
:
80
},
{
field
:
'goods_label_name'
,
title
:
'SKU显示类型'
,
align
:
'center'
,
width
:
120
},
{
field
:
'canal'
,
title
:
'供应商编码'
,
align
:
'center'
,
width
:
120
},
{
field
:
'moq'
,
title
:
'起订量'
,
align
:
'center'
,
width
:
70
...
...
@@ -64,6 +65,11 @@
"
<
a
class
=
'layui-btn layui-btn-xs'
>
否
<
/a>"
;
}
},
{
field
:
'is_prefer'
,
title
:
'精选'
,
align
:
'center'
,
width
:
70
,
templet
:
function
(
d
)
{
return
d
.
is_prefer
?
"是"
:
"否"
;
}
},
{
field
:
'encoded_user_name'
,
title
:
'内部采购'
,
align
:
'center'
,
width
:
100
},
{
field
:
'update_time'
,
title
:
'更新时间'
,
align
:
'center'
,
width
:
150
},
{
field
:
'mpq'
,
title
:
'标准包装量'
,
align
:
'center'
,
width
:
120
},
...
...
resources/views/web/sku/SkuListCommon.blade.php
View file @
650bf243
...
...
@@ -73,16 +73,19 @@
</div>
<div
class=
"layui-inline"
>
@inject('statusPresenter','App\Presenters\StatusPresenter')
{!! $statusPresenter->render('
status/condition','是否过期',request()->get('status/condition'),[0=>'是',1=>'否']
) !!}
{!! $statusPresenter->render('
goods_label/condition','SKU显示类型','',config('field.SkuGoodsLabel')
) !!}
</div>
<div
class=
"layui-inline"
>
@inject('statusPresenter','App\Presenters\StatusPresenter')
{!! $statusPresenter->render('
goods_label/condition','SKU显示类型','',config('field.SkuGoodsLabel')
) !!}
{!! $statusPresenter->render('
tags/condition','是否精选',request()->get('tags/condition'),[1=>'是',0=>'否']
) !!}
</div>
</div>
<div
class=
"layui-row"
>
<div
class=
"layui-inline"
>
<label
class=
"layui-form-label"
>
起订量和库存
</label>
@inject('statusPresenter','App\Presenters\StatusPresenter')
{!! $statusPresenter->render('status/condition','是否过期',request()->get('status/condition'),[0=>'是',1=>'否']) !!}
</div>
<div
class=
"layui-inline"
>
<label
class=
"layui-form-label"
>
起订量库存
</label>
<div
class=
"layui-input-inline"
>
<select
name=
"moq_stock_compare"
>
<option
value=
""
>
请选择
</option>
...
...
@@ -116,6 +119,9 @@
{!! $statusPresenter->render('encoded/condition','上传人',request()->get('encoded/condition'),
$userCodes) !!}
</div>
</div>
<div
class=
"layui-row"
>
<div
class=
"layui-inline"
style=
"width: 600px"
>
@inject('transformableTimeIntervalPresenter','App\Presenters\Filter\TransformableTimeIntervalPresenter')
{!! $transformableTimeIntervalPresenter->render(['update_time'=>'更新时间','create_time'=>'上传时间']) !!}
...
...
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