Toggle navigation
Toggle navigation
This project
Loading...
Sign in
ufo
/
yohoufo-fore
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
mali
6 years ago
Commit
6a096a433e6165572d4f132eaa807a779b03dbeb
1 parent
99b4d66d
闲鱼详情
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
58 additions
and
0 deletions
dal/src/main/java/com/yohoufo/dal/product/StoragePriceMapper.java
dal/src/main/resources/META-INF/mybatis/product/StoragePriceMapper.xml
product/src/main/java/com/yohoufo/product/service/impl/ProductServiceImpl.java
product/src/main/java/com/yohoufo/product/service/impl/StoragePriceService.java
dal/src/main/java/com/yohoufo/dal/product/StoragePriceMapper.java
View file @
6a096a4
...
...
@@ -91,4 +91,11 @@ public interface StoragePriceMapper {
* @return
*/
int
updateBatchDepotNum
(
@Param
(
"skupList"
)
List
<
Integer
>
skupList
,
@Param
(
"depotNum"
)
Integer
depotNo
);
/**
* 查询现货各尺码的最低价
* @param productId
* @return
*/
List
<
StoragePrice
>
selectInStockLeastPByProductId
(
@Param
(
"productId"
)
Integer
productId
);
}
\ No newline at end of file
...
...
dal/src/main/resources/META-INF/mybatis/product/StoragePriceMapper.xml
View file @
6a096a4
...
...
@@ -270,4 +270,13 @@
#{item}
</foreach>
</update>
<select
id=
"selectInStockLeastPByProductId"
resultMap=
"BaseResultMap"
>
select * from (
select id, skup, storage_id, price, status, pre_sale_flag, region
from storage_price
where status = 1 and product_id = #{productId} and is_hide = 0 and region = 0 and pre_sale_flag = 0
order by storage_id,price asc limit 1000000
) a group by storage_id
</select>
</mapper>
\ No newline at end of file
...
...
product/src/main/java/com/yohoufo/product/service/impl/ProductServiceImpl.java
View file @
6a096a4
...
...
@@ -158,6 +158,9 @@ public class ProductServiceImpl implements ProductService {
@Autowired
private
StorageService
storageService
;
@Autowired
private
StoragePriceService
storagePriceService
;
@Override
public
ProductDetailResp
queryProductDetailById
(
Integer
productId
)
{
ProductDetailResp
productDetailResp
=
new
ProductDetailResp
();
...
...
@@ -2253,6 +2256,8 @@ public class ProductServiceImpl implements ProductService {
if
(!
CollectionUtils
.
isEmpty
(
goodsBOList
))
{
List
<
GoodsSize
>
goodsSizes
=
storageService
.
getSizeList
(
productId
,
goodsBOList
.
get
(
0
));
storagePriceService
.
setStoragePrice
(
goodsSizes
,
productId
);
// 设置库存,最低价 skup等信息
goodsBOList
.
get
(
0
).
setSizeList
(
goodsSizes
);
storageService
.
setMaxMinPrice
(
goodsSizes
,
product
.
getMinPrice
(),
product
.
getMaxPrice
());
//设置商品最高价和最低价
...
...
product/src/main/java/com/yohoufo/product/service/impl/StoragePriceService.java
View file @
6a096a4
package
com
.
yohoufo
.
product
.
service
.
impl
;
import
com.yohobuy.ufo.model.GoodsSize
;
import
com.yohoufo.dal.product.StoragePriceMapper
;
import
com.yohoufo.dal.product.model.StoragePrice
;
import
com.yohoufo.product.cache.UfoProductCacheService
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.ibatis.annotations.Param
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
/**
* Created by li.ma on 2019/6/27.
...
...
@@ -24,4 +31,34 @@ public class StoragePriceService {
}
/**
* 查询现货各尺码的最低价
* @param productId
* @return
*/
private
Map
<
Integer
,
StoragePrice
>
selectInStockLeastPByProductId
(
@Param
(
"productId"
)
Integer
productId
)
{
return
storagePriceMapper
.
selectInStockLeastPByProductId
(
productId
).
stream
().
collect
(
Collectors
.
toMap
(
StoragePrice:
:
getStorageId
,
Function
.
identity
()));
}
public
void
setStoragePrice
(
List
<
GoodsSize
>
goodsSizes
,
Integer
productId
)
{
if
(
CollectionUtils
.
isEmpty
(
goodsSizes
))
{
return
;
}
Map
<
Integer
,
StoragePrice
>
storagePriceMap
=
selectInStockLeastPByProductId
(
productId
);
goodsSizes
.
stream
().
forEach
(
item
->
{
StoragePrice
storagePrice
=
storagePriceMap
.
get
(
item
.
getId
());
//大陆现货
if
(
null
!=
storagePrice
&&
null
!=
item
.
getSuggestHighPrice
()
&&
storagePrice
.
getPrice
().
compareTo
(
item
.
getSuggestHighPrice
())
>
0
)
{
//高于建议价,不展示skup
item
.
setStorageNum
(
0
);
item
.
setSkup
(
0
);
}
else
{
item
.
setLeastPrice
(
storagePrice
==
null
?
null
:
storagePrice
.
getPrice
());
item
.
setStatus
(
storagePrice
==
null
?
null
:
storagePrice
.
getStatus
());
item
.
setSkup
(
storagePrice
==
null
?
0
:
storagePrice
.
getSkup
());
item
.
setStorageNum
(
item
.
getSkup
()
==
null
||
item
.
getSkup
()
==
0
?
0
:
1
);
}
});
}
}
...
...
Please
register
or
login
to post a comment