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
83f5d9d7
authored
Aug 13, 2021
by
mushishixian
Browse files
Options
_('Browse Files')
Download
Plain Diff
修复冲突
parents
485ef207
650bf243
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
225 additions
and
8 deletions
app/Http/Controllers/Api/SkuApiController.php
app/Http/Controllers/Filter/SkuListFilter.php
app/Http/Services/SkuService.php
app/Http/Services/SupplierSearchTagService.php
app/Http/Services/SupplierService.php
config/field.php
resources/views/script/SkuListScript.blade.php
resources/views/web/SkuList.blade.php
resources/views/web/sku/SkuListCommon.blade.php
app/Http/Controllers/Api/SkuApiController.php
View file @
83f5d9d7
...
@@ -87,4 +87,21 @@ class SkuApiController extends Controller
...
@@ -87,4 +87,21 @@ class SkuApiController extends Controller
$this
->
response
(
-
1
,
'批量下架失败'
);
$this
->
response
(
-
1
,
'批量下架失败'
);
}
}
}
}
//设置精选Sku
public
function
SetPreferSku
(
$request
)
{
$prefer
=
$request
->
get
(
'prefer'
);
$skuIds
=
$request
->
input
(
'sku_id'
);
if
(
empty
(
$skuIds
)
||
!
is_array
(
$skuIds
))
{
$this
->
response
(
-
1
,
'请选择要操作的SKU'
,
'0'
);
}
$skuService
=
new
SkuService
();
$result
=
$skuService
->
setPreferSku
(
$skuIds
,
$prefer
);
if
(
$result
)
{
$this
->
response
(
0
,
'操作成功'
);
}
else
{
$this
->
response
(
-
1
,
'操作失败,原因是 : '
.
$result
[
'errmsg'
]);
}
}
}
}
app/Http/Controllers/Filter/SkuListFilter.php
View file @
83f5d9d7
...
@@ -13,7 +13,7 @@ class SkuListFilter
...
@@ -13,7 +13,7 @@ class SkuListFilter
public
function
listFilter
()
public
function
listFilter
()
{
{
$map
=
request
()
->
all
();
$map
=
request
()
->
all
();
//dd($map);
//只获取专卖的数据
//只获取专卖的数据
$map
[
'supplier_id'
]
=
17
;
$map
[
'supplier_id'
]
=
17
;
if
((
!
empty
(
$map
[
'create_time'
])))
{
if
((
!
empty
(
$map
[
'create_time'
])))
{
...
@@ -66,7 +66,6 @@ class SkuListFilter
...
@@ -66,7 +66,6 @@ class SkuListFilter
unset
(
$map
[
$k
]);
unset
(
$map
[
$k
]);
}
}
}
}
$map
[
'p'
]
=
$map
[
'page'
];
$map
[
'p'
]
=
$map
[
'page'
];
unset
(
$map
[
'page'
]);
unset
(
$map
[
'page'
]);
...
...
app/Http/Services/SkuService.php
View file @
83f5d9d7
...
@@ -43,12 +43,12 @@ class SkuService
...
@@ -43,12 +43,12 @@ class SkuService
$sku
[
'is_expire'
]
=
$data
[
'data'
][
'status'
][
$goodsId
]
&&
$data
[
'data'
][
'status'
][
$goodsId
]
>
0
?
0
:
1
;
$sku
[
'is_expire'
]
=
$data
[
'data'
][
'status'
][
$goodsId
]
&&
$data
[
'data'
][
'status'
][
$goodsId
]
>
0
?
0
:
1
;
$spu
=
json_decode
(
$redis
->
hget
(
'spu'
,
$sku
[
'spu_id'
]),
true
);
$spu
=
json_decode
(
$redis
->
hget
(
'spu'
,
$sku
[
'spu_id'
]),
true
);
//型号处理
//型号处理
if
(
empty
(
$sku
[
'goods_name'
])
&&
!
empty
(
$spu
))
{
if
(
empty
(
$sku
[
'goods_name'
])
&&
!
empty
(
$spu
))
{
$sku
[
'goods_name'
]
=
$spu
[
'spu_name'
];
$sku
[
'goods_name'
]
=
$spu
[
'spu_name'
];
}
}
$sku
[
'encap'
]
=
array_get
(
$spu
,
'encap'
,
''
);
$sku
[
'encap'
]
=
array_get
(
$spu
,
'encap'
,
''
);
//制造商处理
//制造商处理
if
(
empty
(
$sku
[
'brand_name'
])
&&
!
empty
(
$spu
))
{
if
(
empty
(
$sku
[
'brand_name'
])
&&
!
empty
(
$spu
))
{
$brand
=
$redis
->
hget
(
'brand_id'
,
$spu
[
'brand_id'
]);
$brand
=
$redis
->
hget
(
'brand_id'
,
$spu
[
'brand_id'
]);
if
(
$brand
)
{
if
(
$brand
)
{
$sku
[
'brand_name'
]
=
$brand
;
$sku
[
'brand_name'
]
=
$brand
;
...
@@ -68,6 +68,12 @@ class SkuService
...
@@ -68,6 +68,12 @@ class SkuService
}
}
$sku
[
'cn_price'
]
=
array_get
(
$moqPrice
,
'price_cn'
);
$sku
[
'cn_price'
]
=
array_get
(
$moqPrice
,
'price_cn'
);
$sku
[
'us_price'
]
=
array_get
(
$moqPrice
,
'price_us'
);
$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
;
$list
[]
=
$sku
;
}
}
$intracodeModel
=
new
IntracodeModel
();
$intracodeModel
=
new
IntracodeModel
();
...
@@ -86,4 +92,48 @@ class SkuService
...
@@ -86,4 +92,48 @@ class SkuService
'total'
=>
!
empty
(
$data
[
'data'
][
'total'
])
?
$data
[
'data'
][
'total'
]
:
0
'total'
=>
!
empty
(
$data
[
'data'
][
'total'
])
?
$data
[
'data'
][
'total'
]
:
0
];
];
}
}
//设置精选
public
function
setPreferSku
(
$skuIds
,
$prefer
)
{
//直接操作redis的goods_tag,然后推送es的修改任务即可
$redis
=
new
RedisModel
();
foreach
(
$skuIds
as
$skuId
)
{
$goodsTag
=
$redis
->
hget
(
'goods_tag'
,
$skuId
);
$goodsTag
=
json_decode
(
$goodsTag
,
true
);
if
(
!
empty
(
$goodsTag
))
{
$tag
=
$goodsTag
[
'tags'
];
//判断是否有精选标签(1),而且操作是取消精选
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
app/Http/Services/SupplierSearchTagService.php
0 → 100644
View file @
83f5d9d7
<?php
namespace
App\Http\Services
;
use
App\Model\RedisModel
;
use
App\Model\SupplierChannelModel
;
use
PhpAmqpLib\Connection\AMQPStreamConnection
;
use
PhpAmqpLib\Message\AMQPMessage
;
//这个服务是专门给搜索那边处理数据用的,供应商这边修改了标签以后,如果有变化,会影响对应的所有sku的标签
class
SupplierSearchTagService
{
//保存标签情况(搜索相关,不是系统标签和自定义标签)
//供应商性质为原厂(4)的话,写入标签2;已认证的话,写入标签3
public
function
saveSupplierSearchTags
(
$supplierId
)
{
$supplierModel
=
new
SupplierChannelModel
();
$supplier
=
$supplierModel
->
where
(
'supplier_id'
,
$supplierId
)
->
first
()
->
toArray
();
$tagFlags
=
[];
//先去判断供应商性质是否为原厂,如果是的话,写入标签2
if
(
$supplier
[
'supplier_group'
]
==
4
)
{
$tagFlags
[]
=
2
;
}
if
(
$supplier
[
'has_certification'
]
==
1
)
{
$tagFlags
[]
=
3
;
}
$redis
=
new
RedisModel
();
$originTags
=
$redis
->
hget
(
'supplier_search_tags'
,
$supplier
[
'supplier_code'
]);
$tagFlags
=
json_encode
([
'supplier_code'
=>
$supplier
[
'supplier_code'
],
'tags'
=>
$tagFlags
,
]);
$redis
->
hset
(
'supplier_search_tags'
,
$supplier
[
'supplier_code'
],
$tagFlags
);
//判断是否发生变化,有变化才推送
if
(
$originTags
!=
$tagFlags
)
{
//{"supplier_code":"L00055"}
$message
=
json_encode
([
'supplier_code'
=>
$supplier
[
'supplier_code'
],
]);
$conn
=
new
AMQPStreamConnection
(
config
(
'database.connections.rabbitmq.host'
),
config
(
'database.connections.rabbitmq.port'
),
config
(
'database.connections.rabbitmq.login'
),
config
(
'database.connections.rabbitmq.password'
));
$channel
=
$conn
->
channel
();
$channel
->
queue_declare
(
'supplier_zhuanmai_update'
,
false
,
true
,
false
,
false
);
$msg
=
new
AMQPMessage
(
json_encode
(
$message
),
array
(
'content_type'
=>
'text/plain'
));
$result
=
$channel
->
basic_publish
(
$msg
,
''
,
'supplier_zhuanmai_update'
);
}
}
}
\ No newline at end of file
app/Http/Services/SupplierService.php
View file @
83f5d9d7
...
@@ -163,6 +163,9 @@ class SupplierService
...
@@ -163,6 +163,9 @@ class SupplierService
$attachmentService
->
saveAttachment
(
$supplierId
,
$attachment
);
$attachmentService
->
saveAttachment
(
$supplierId
,
$attachment
);
//重新生成外部显示的编码
//重新生成外部显示的编码
$this
->
generateSupplierSn
(
$supplierId
,
$channel
[
'supplier_group'
]);
$this
->
generateSupplierSn
(
$supplierId
,
$channel
[
'supplier_group'
]);
//保存和搜索相关的标签情况
$supplierSearchTagService
=
new
SupplierSearchTagService
();
$supplierSearchTagService
->
saveSupplierSearchTags
(
$supplierId
);
return
true
;
return
true
;
});
});
...
@@ -434,4 +437,5 @@ class SupplierService
...
@@ -434,4 +437,5 @@ class SupplierService
]);
]);
}
}
}
}
}
}
\ No newline at end of file
config/field.php
View file @
83f5d9d7
...
@@ -42,6 +42,13 @@ return [
...
@@ -42,6 +42,13 @@ return [
'cp_time'
=>
1
,
'cp_time'
=>
1
,
],
],
//1 国内现货,2国际现货, 3 猎芯期货
'SkuGoodsLabel'
=>
[
1
=>
'国内现货'
,
2
=>
'国际现货'
,
3
=>
'猎芯期货'
,
],
//SKU 标签
//SKU 标签
'SkuTag'
=>
[
'SkuTag'
=>
[
1
=>
'优选'
,
1
=>
'优选'
,
...
...
resources/views/script/SkuListScript.blade.php
View file @
83f5d9d7
...
@@ -26,7 +26,7 @@
...
@@ -26,7 +26,7 @@
,
where
:
whereCondition
,
where
:
whereCondition
});
});
let
buttonName
=
$
(
this
).
attr
(
'id'
);
let
buttonName
=
$
(
this
).
attr
(
'id'
);
if
(
buttonName
===
'off_shelf'
)
{
if
(
buttonName
===
'off_shelf'
)
{
//同时还要去联动下面的状态筛选
//同时还要去联动下面的状态筛选
let
id
=
'goods_status\\/condition'
;
let
id
=
'goods_status\\/condition'
;
$
(
'#'
+
id
).
val
(
3
);
$
(
'#'
+
id
).
val
(
3
);
...
@@ -41,6 +41,7 @@
...
@@ -41,6 +41,7 @@
field
:
'brand_name'
,
title
:
'品牌'
,
align
:
'center'
,
width
:
120
field
:
'brand_name'
,
title
:
'品牌'
,
align
:
'center'
,
width
:
120
},
},
{
field
:
'encap'
,
title
:
'封装'
,
align
:
'center'
,
width
:
80
},
{
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
:
'canal'
,
title
:
'供应商编码'
,
align
:
'center'
,
width
:
120
},
{
{
field
:
'moq'
,
title
:
'起订量'
,
align
:
'center'
,
width
:
70
field
:
'moq'
,
title
:
'起订量'
,
align
:
'center'
,
width
:
70
...
@@ -64,6 +65,11 @@
...
@@ -64,6 +65,11 @@
"
<
a
class
=
'layui-btn layui-btn-xs'
>
否
<
/a>"
;
"
<
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
:
'encoded_user_name'
,
title
:
'内部采购'
,
align
:
'center'
,
width
:
100
},
{
field
:
'update_time'
,
title
:
'更新时间'
,
align
:
'center'
,
width
:
150
},
{
field
:
'update_time'
,
title
:
'更新时间'
,
align
:
'center'
,
width
:
150
},
{
field
:
'mpq'
,
title
:
'标准包装量'
,
align
:
'center'
,
width
:
120
},
{
field
:
'mpq'
,
title
:
'标准包装量'
,
align
:
'center'
,
width
:
120
},
...
@@ -180,6 +186,36 @@
...
@@ -180,6 +186,36 @@
batchUpdateGoodsStatus
(
skuIds
,
'offshelf'
);
batchUpdateGoodsStatus
(
skuIds
,
'offshelf'
);
})
})
//批量下架
$
(
"#set_prefer"
).
click
(
function
()
{
let
checkStatus
=
table
.
checkStatus
(
'skuList'
);
let
data
=
checkStatus
.
data
;
let
skuIds
=
[];
$
.
each
(
data
,
function
(
index
,
value
)
{
skuIds
.
push
(
value
.
goods_id
);
});
if
(
skuIds
.
length
===
0
)
{
layer
.
msg
(
'请选择要操作的sku'
,
{
icon
:
5
});
return
;
}
batchSetSkuPrefer
(
skuIds
,
'set_prefer'
);
})
//批量下架
$
(
"#cancel_set_prefer"
).
click
(
function
()
{
let
checkStatus
=
table
.
checkStatus
(
'skuList'
);
let
data
=
checkStatus
.
data
;
let
skuIds
=
[];
$
.
each
(
data
,
function
(
index
,
value
)
{
skuIds
.
push
(
value
.
goods_id
);
});
if
(
skuIds
.
length
===
0
)
{
layer
.
msg
(
'请选择要操作的sku'
,
{
icon
:
5
});
return
;
}
batchSetSkuPrefer
(
skuIds
,
'cancel_set_prefer'
);
})
//根据供应商编码已经品牌等去基石调用接口下架
//根据供应商编码已经品牌等去基石调用接口下架
$
(
"#remote_batch_off_shelf"
).
click
(
function
()
{
$
(
"#remote_batch_off_shelf"
).
click
(
function
()
{
layer
.
open
({
layer
.
open
({
...
@@ -229,6 +265,42 @@
...
@@ -229,6 +265,42 @@
});
});
}
}
//批量设置精选
function
batchSetSkuPrefer
(
skuId
,
isPrefer
)
{
let
label
=
isPrefer
===
'set_prefer'
?
'设置精选'
:
'取消设置精选'
;
let
prefer
=
isPrefer
===
'set_prefer'
?
1
:
-
1
;
layer
.
confirm
(
'确定要将选中的这些商品'
+
label
+
'吗'
,
function
(
index
)
{
$
.
ajax
({
type
:
'post'
,
url
:
'/api/sku/SetPreferSku'
,
timeout
:
30000
,
//超时时间设置,单位毫秒
data
:
{
sku_id
:
skuId
,
prefer
:
prefer
},
dataType
:
'json'
,
success
:
function
(
resp
)
{
close
();
if
(
!
resp
)
{
layer
.
msg
(
'网络连接失败'
,
{
icon
:
5
});
return
false
;
}
if
(
resp
.
err_code
===
0
)
{
layer
.
msg
(
'操作成功'
,
{
icon
:
6
});
table
.
reload
(
'skuList'
,
{
page
:
{
curr
:
currentPage
},
});
}
else
{
return
false
;
}
}
});
layer
.
closeAll
();
});
}
form
.
on
(
'submit(load)'
,
function
(
data
)
{
form
.
on
(
'submit(load)'
,
function
(
data
)
{
$
(
'.main_filter'
).
attr
(
'class'
,
'main_filter'
);
$
(
'.main_filter'
).
attr
(
'class'
,
'main_filter'
);
$
(
'#all'
).
attr
(
'class'
,
'main_filter layui-badge layui-bg-green'
);
$
(
'#all'
).
attr
(
'class'
,
'main_filter layui-badge layui-bg-green'
);
...
...
resources/views/web/SkuList.blade.php
View file @
83f5d9d7
...
@@ -7,6 +7,8 @@
...
@@ -7,6 +7,8 @@
<button type="
button
" class="
layui
-
btn
layui
-
btn
-
sm
" id="
batch_putaway
">上架</button>
<button type="
button
" class="
layui
-
btn
layui
-
btn
-
sm
" id="
batch_putaway
">上架</button>
<button type="
button
" class="
layui
-
btn
layui
-
btn
-
sm
" id="
batch_off_shelf
">下架</button>
<button type="
button
" class="
layui
-
btn
layui
-
btn
-
sm
" id="
batch_off_shelf
">下架</button>
<button type="
button
" class="
layui
-
btn
layui
-
btn
-
sm
" id="
remote_batch_off_shelf
">批量下架</button>
<button type="
button
" class="
layui
-
btn
layui
-
btn
-
sm
" id="
remote_batch_off_shelf
">批量下架</button>
<button type="
button
" class="
layui
-
btn
layui
-
btn
-
sm
" id="
set_prefer
">设置精选</button>
<button type="
button
" class="
layui
-
btn
layui
-
btn
-
sm
" id="
cancel_set_prefer
">取消精选</button>
</div>
</div>
<table class="
layui
-
table
" id="
skuList
" lay-filter="
skuList
"></table>
<table class="
layui
-
table
" id="
skuList
" lay-filter="
skuList
"></table>
...
...
resources/views/web/sku/SkuListCommon.blade.php
View file @
83f5d9d7
...
@@ -73,12 +73,19 @@
...
@@ -73,12 +73,19 @@
</div>
</div>
<div
class=
"layui-inline"
>
<div
class=
"layui-inline"
>
@inject('statusPresenter','App\Presenters\StatusPresenter')
@inject('statusPresenter','App\Presenters\StatusPresenter')
{!! $statusPresenter->render('goods_label/condition','SKU显示类型','',config('field.SkuGoodsLabel')) !!}
</div>
<div
class=
"layui-inline"
>
@inject('statusPresenter','App\Presenters\StatusPresenter')
{!! $statusPresenter->render('tags/condition','是否精选',request()->get('tags/condition'),[1=>'是',0=>'否']) !!}
</div>
<div
class=
"layui-inline"
>
@inject('statusPresenter','App\Presenters\StatusPresenter')
{!! $statusPresenter->render('status/condition','是否过期',request()->get('status/condition'),[0=>'是',1=>'否']) !!}
{!! $statusPresenter->render('status/condition','是否过期',request()->get('status/condition'),[0=>'是',1=>'否']) !!}
</div>
</div>
</div>
<div
class=
"layui-row"
>
<div
class=
"layui-inline"
>
<div
class=
"layui-inline"
>
<label
class=
"layui-form-label"
>
起订量
和
库存
</label>
<label
class=
"layui-form-label"
>
起订量库存
</label>
<div
class=
"layui-input-inline"
>
<div
class=
"layui-input-inline"
>
<select
name=
"moq_stock_compare"
>
<select
name=
"moq_stock_compare"
>
<option
value=
""
>
请选择
</option>
<option
value=
""
>
请选择
</option>
...
@@ -112,6 +119,9 @@
...
@@ -112,6 +119,9 @@
{!! $statusPresenter->render('encoded/condition','上传人',request()->get('encoded/condition'),
{!! $statusPresenter->render('encoded/condition','上传人',request()->get('encoded/condition'),
$userCodes) !!}
$userCodes) !!}
</div>
</div>
</div>
<div
class=
"layui-row"
>
<div
class=
"layui-inline"
style=
"width: 600px"
>
<div
class=
"layui-inline"
style=
"width: 600px"
>
@inject('transformableTimeIntervalPresenter','App\Presenters\Filter\TransformableTimeIntervalPresenter')
@inject('transformableTimeIntervalPresenter','App\Presenters\Filter\TransformableTimeIntervalPresenter')
{!! $transformableTimeIntervalPresenter->render(['update_time'=>'更新时间','create_time'=>'上传时间']) !!}
{!! $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