@ -45,10 +45,7 @@ import com.suisung.mall.common.pojo.dto.BaiduAiBriefDTO;
import com.suisung.mall.common.pojo.dto.ProductRecommendDTO ;
import com.suisung.mall.common.pojo.dto.ProductSearchDTO ;
import com.suisung.mall.common.service.MessageService ;
import com.suisung.mall.common.utils.CSVUtils ;
import com.suisung.mall.common.utils.CheckUtil ;
import com.suisung.mall.common.utils.CommonUtil ;
import com.suisung.mall.common.utils.I18nUtil ;
import com.suisung.mall.common.utils.* ;
import com.suisung.mall.core.web.service.impl.BaseServiceImpl ;
import com.suisung.mall.shop.activity.service.ShopActivityGroupbookingService ;
import com.suisung.mall.shop.base.service.* ;
@ -6460,5 +6457,99 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
return shopProductBaseMapper . findPageMapping ( store_id , ( pageNum - 1 ) * pageSize , pageSize ) ;
}
@Override
public Map getProductByProductNumber ( String productNumber ) {
UserDto userDto = ContextUtil . getCurrentUser ( ) ;
String store_id = userDto . getStore_id ( ) ;
Map data = new HashMap ( ) ;
QueryWrapper < ShopProductIndex > cond_row = new QueryWrapper < > ( ) ;
if ( StrUtil . isNotBlank ( productNumber ) ) {
cond_row . eq ( " product_number " , productNumber ) ;
}
cond_row . eq ( " store_id " , store_id ) ;
List < ShopProductIndex > lists = shopProductIndexService . list ( cond_row ) ;
if ( lists . isEmpty ( ) ) {
return null ;
}
ShopProductIndex shopProductIndexFind = lists . get ( 0 ) ;
/ / todo lc
/ / data . put ( " productBase " , shopProductIndexFind ) ;
/ / 判断是否为商家 , 且开启供应商 , 判断是否已经加入分销中
Long productId = shopProductIndexFind . getProduct_id ( ) ;
List < Integer > product_ids = Collections . singletonList ( Math . toIntExact ( productId ) ) ;
data . put ( " baseInfo " , getProduct ( product_ids ) ) ;
List < Map > baseInfo = ( List < Map > ) data . get ( " baseInfo " ) ;
baseInfo . forEach ( s - > {
String str_product_spec = ( String ) s . get ( " product_spec " ) ;
if ( StrUtil . isNotBlank ( str_product_spec ) & & StrUtil . equals ( str_product_spec , " [] " ) ) {
s . put ( " product_spec " , JSONUtil . parseArray ( str_product_spec ) ) ;
}
String str_product_assist = ( String ) s . get ( " product_assist " ) ;
if ( StrUtil . isNotBlank ( str_product_assist ) & & StrUtil . equals ( str_product_assist , " {} " ) ) {
s . put ( " product_assist " , JSONUtil . parseObj ( str_product_assist ) ) ;
}
} ) ;
QueryWrapper < ShopProductItem > itemQueryWrapper = new QueryWrapper < > ( ) ;
itemQueryWrapper . eq ( " product_id " , productId ) ;
List < ShopProductItem > productItems = shopProductItemService . find ( itemQueryWrapper ) ;
if ( CollectionUtil . isNotEmpty ( productItems ) ) {
for ( Map item : baseInfo ) {
List < ShopProductItem > shopProductItems = productItems . stream ( ) . filter ( s - > ObjectUtil . equal ( s . getProduct_id ( ) , productId ) ) . collect ( Collectors . toList ( ) ) ;
if ( CollectionUtil . isNotEmpty ( shopProductItems ) ) {
BigDecimal product_advice_price = shopProductItems . stream ( ) . map ( ShopProductItem : : getItem_advice_price ) . min ( BigDecimal : : compareTo ) . get ( ) ;
item . put ( " product_advice_price " , product_advice_price ) ;
}
}
}
List < ShopProductItem > productItemS = productItems . stream ( ) . filter ( distinctByKey ( o - > o . getProduct_id ( ) ) ) . collect ( Collectors . toList ( ) ) ;
data . put ( " items " , productItemS ) ; / / 商品规格列表
/ / shop_product_info
ShopProductInfo shopProductInfo = shopProductInfoService . get ( productId ) ;
/ / shop_product_detail
ShopProductDetail shopProductDetail = shopProductDetailService . get ( productId ) ;
/ / shop_product_index
ShopProductIndex shopProductIndex = shopProductIndexService . get ( productId ) ;
/ / shop_product_image
QueryWrapper < ShopProductImage > imageQueryWrapper = new QueryWrapper < > ( ) ;
imageQueryWrapper . eq ( " product_id " , productId ) ;
List < ShopProductImage > shopProductImages = shopProductImageService . find ( imageQueryWrapper ) ;
/ / shop_product_assist_index
QueryWrapper < ShopProductAssistIndex > indexQueryWrapper = new QueryWrapper < > ( ) ;
indexQueryWrapper . eq ( " product_id " , productId ) ;
List < ShopProductAssistIndex > assistIndexList = assistIndexService . find ( indexQueryWrapper ) ;
HashMap < String , Object > map = new HashMap < > ( ) ;
if ( com . suisung . mall . common . utils . StringUtils . isEmpty ( shopProductInfo . getProduct_spec ( ) ) ) {
shopProductInfo . setProduct_spec ( " [] " ) ;
}
map . put ( " shop_product_info " , shopProductInfo ) ;
map . put ( " shop_product_image " , shopProductImages ) ;
map . put ( " shop_product_detail " , shopProductDetail ) ;
map . put ( " shop_product_index " , shopProductIndex ) ;
map . put ( " shop_product_assist_index " , assistIndexList ) ;
/ / 虚拟商品信息表
Integer kind_id = shopProductIndex . getKind_id ( ) ;
if ( ObjectUtil . equal ( kind_id , StateCode . PRODUCT_KIND_FUWU ) ) {
ShopProductValidPeriod validPeriod = shopProductValidPeriodService . get ( productId ) ;
map . put ( " shop_product_valid_period " , validPeriod ) ;
}
data . put ( " productInfo " , map ) ;
Integer category_id = productItems . get ( 0 ) . getCategory_id ( ) ;
ShopBaseProductCategory shopBaseProductCategory = shopBaseProductCategoryService . get ( category_id ) ;
data . put ( " category " , shopBaseProductCategory ) ;
Integer typeId = shopBaseProductCategory . getType_id ( ) ;
data . put ( " shopBaseProductType " , shopBaseProductTypeService . getType ( String . valueOf ( typeId ) , productId ) ) ;
return data ;
}
}