Commit 9d6ff401 authored by shiyu's avatar shiyu

个人藏馆2

parent e5928881
...@@ -45,5 +45,12 @@ public interface SupplierItemDao { ...@@ -45,5 +45,12 @@ public interface SupplierItemDao {
*/ */
int delete(long itemId); int delete(long itemId);
/**
* 首页查询商品列表
* @param supplierItemRequestDto
* @return
*/
List<SupplierItem> findForHomePage(SupplierItemRequestDto supplierItemRequestDto);
} }
...@@ -2,6 +2,8 @@ package com.wwdz.ch.db.dao.distribution; ...@@ -2,6 +2,8 @@ package com.wwdz.ch.db.dao.distribution;
import com.wwdz.ch.db.domain.distribution.UserRecentBrowse; import com.wwdz.ch.db.domain.distribution.UserRecentBrowse;
import java.util.List;
public interface UserRecentBrowseDao { public interface UserRecentBrowseDao {
/** /**
...@@ -16,7 +18,7 @@ public interface UserRecentBrowseDao { ...@@ -16,7 +18,7 @@ public interface UserRecentBrowseDao {
* @param userId * @param userId
* @return * @return
*/ */
UserRecentBrowse findByUserId(long userId); List<UserRecentBrowse> findByUserId(long userId);
/** /**
......
...@@ -43,5 +43,8 @@ public class CollectionBookRequestDto extends BaseRequestDto implements Entity ...@@ -43,5 +43,8 @@ public class CollectionBookRequestDto extends BaseRequestDto implements Entity
*/ */
private Boolean isDeleted; private Boolean isDeleted;
/**
* 是否返回"我收藏的"标签
*/
private Boolean isHasExtraLabel;
} }
...@@ -115,10 +115,15 @@ public class SupplierItemRequestDto extends BaseRequestDto implements Entity { ...@@ -115,10 +115,15 @@ public class SupplierItemRequestDto extends BaseRequestDto implements Entity {
private String rebate; private String rebate;
/** /**
* 商品类型1一口价2竞拍 * 商品类型1一口价2竞拍3用户上传
*/ */
private Integer type; private Integer type;
/**
* 商品类型1一口价2竞拍3用户上传
*/
private List<Integer> typeList;
/** /**
* 竞拍开始时间 * 竞拍开始时间
*/ */
...@@ -157,6 +162,11 @@ public class SupplierItemRequestDto extends BaseRequestDto implements Entity { ...@@ -157,6 +162,11 @@ public class SupplierItemRequestDto extends BaseRequestDto implements Entity {
*/ */
private Long creatorId; private Long creatorId;
/**
* 上传人id
*/
private List<Long> creatorIdList;
} }
...@@ -80,4 +80,20 @@ public class SupplierItemDaoImpl implements SupplierItemDao { ...@@ -80,4 +80,20 @@ public class SupplierItemDaoImpl implements SupplierItemDao {
supplierItem.setUpdateTime(new Date()); supplierItem.setUpdateTime(new Date());
return supplierItemMapper.updateByPrimaryKeySelective(supplierItem); return supplierItemMapper.updateByPrimaryKeySelective(supplierItem);
} }
@Override
public List<SupplierItem> findForHomePage(SupplierItemRequestDto dto) {
SupplierItemExample supplierItemExample = new SupplierItemExample();
SupplierItemExample.Criteria criteria = supplierItemExample.createCriteria();
JdbcHelper.ifPresent(dto.getId(), criteria::andIdEqualTo);
JdbcHelper.ifPresent(dto.getIds(), criteria::andIdIn);
JdbcHelper.ifPresent(dto.getType(), criteria::andTypeEqualTo);
JdbcHelper.ifPresent(dto.getStock(), criteria::andStockGreaterThan);
JdbcHelper.ifPresent(dto.getIsOnSale(), criteria::andIsOnSaleEqualTo);
JdbcHelper.ifPresent(dto.getIsDeleted(), criteria::andIsDeletedEqualTo);
supplierItemExample.setOrderByClause(" update_time desc");
PageHelper.startPage(dto.getPage(), dto.getLimit());
return supplierItemMapper.selectByExampleWithBLOBs(supplierItemExample);
}
} }
...@@ -7,6 +7,7 @@ import com.wwdz.ch.db.mapper.distribution.UserRecentBrowseMapper; ...@@ -7,6 +7,7 @@ import com.wwdz.ch.db.mapper.distribution.UserRecentBrowseMapper;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.Date; import java.util.Date;
import java.util.List;
@Repository @Repository
public class UserRecentBrowseDaoImpl implements UserRecentBrowseDao { public class UserRecentBrowseDaoImpl implements UserRecentBrowseDao {
...@@ -23,11 +24,11 @@ public class UserRecentBrowseDaoImpl implements UserRecentBrowseDao { ...@@ -23,11 +24,11 @@ public class UserRecentBrowseDaoImpl implements UserRecentBrowseDao {
} }
@Override @Override
public UserRecentBrowse findByUserId(long userId) { public List<UserRecentBrowse> findByUserId(long userId) {
UserRecentBrowseExample example = new UserRecentBrowseExample(); UserRecentBrowseExample example = new UserRecentBrowseExample();
UserRecentBrowseExample.Criteria criteria = example.createCriteria(); UserRecentBrowseExample.Criteria criteria = example.createCriteria();
criteria.andUserIdEqualTo(userId); criteria.andUserIdEqualTo(userId);
return userRecentBrowseMapper.selectOneByExample(example); return userRecentBrowseMapper.selectByExample(example);
} }
@Override @Override
......
...@@ -55,6 +55,12 @@ public class CollectionBookServiceImpl implements CollectionBookService { ...@@ -55,6 +55,12 @@ public class CollectionBookServiceImpl implements CollectionBookService {
map.put("title", collectionBook.getTitle()); map.put("title", collectionBook.getTitle());
list.add(map); list.add(map);
}); });
if (dto.getIsHasExtraLabel()) {
Map<String, Object> map = new HashMap<>();
map.put("id", 0);
map.put("title", "我收藏的");
list.add(0, map);
}
return Result.success(list); return Result.success(list);
} catch (Exception e) { } catch (Exception e) {
logger.error("查询收藏册 error: {}", e); logger.error("查询收藏册 error: {}", e);
......
...@@ -99,14 +99,6 @@ public class CollectionItemsRelationServiceImpl implements CollectionItemsRelati ...@@ -99,14 +99,6 @@ public class CollectionItemsRelationServiceImpl implements CollectionItemsRelati
collectionBookRequestDto.setUserId(searchUserId); collectionBookRequestDto.setUserId(searchUserId);
Result bookResult = collectionBookService.findList(collectionBookRequestDto); Result bookResult = collectionBookService.findList(collectionBookRequestDto);
if (bookResult.getSuccess()) { if (bookResult.getSuccess()) {
List<Map<String, Object>> bookList = (List<Map<String, Object>>) bookResult.getData();
if (collectionBookVo.getIsMine()) {
//是主态需要加上"我收藏的"这个默认标签,默认标签id为0
Map<String, Object> map = new HashMap<>();
map.put("id", 0);
map.put("title", "我收藏的");
bookList.add(0, map);
}
collectionBookVo.setBookList((List<Map<String, Object>>) bookResult.getData()); collectionBookVo.setBookList((List<Map<String, Object>>) bookResult.getData());
} }
//查询所有的上传藏品 //查询所有的上传藏品
...@@ -124,8 +116,9 @@ public class CollectionItemsRelationServiceImpl implements CollectionItemsRelati ...@@ -124,8 +116,9 @@ public class CollectionItemsRelationServiceImpl implements CollectionItemsRelati
supplierItemVo.setHomePageImage(MediaUtil.getHomePageImage(supplierItem.getImages(), supplierItem.getVideos())); supplierItemVo.setHomePageImage(MediaUtil.getHomePageImage(supplierItem.getImages(), supplierItem.getVideos()));
list.add(supplierItemVo); list.add(supplierItemVo);
}); });
collectionBookVo.setPageSearchResult(PageSearchResult.of(pageInfo, list)); PageSearchResult pageSearchResult = PageSearchResult.of(pageInfo, list);
return Result.success(collectionBookVo); pageSearchResult.setAppendObject(collectionBookVo);
return Result.success(pageSearchResult);
} catch (Exception e) { } catch (Exception e) {
logger.error("查询个人藏馆信息失败 error: {}", e); logger.error("查询个人藏馆信息失败 error: {}", e);
} }
......
...@@ -92,6 +92,8 @@ public class SupplierItemServiceImpl implements SupplierItemService { ...@@ -92,6 +92,8 @@ public class SupplierItemServiceImpl implements SupplierItemService {
@Autowired @Autowired
CollectionShareRecordDao collectionShareRecordDao; CollectionShareRecordDao collectionShareRecordDao;
@Override @Override
public Result findList(SupplierItemRequestDto dto) { public Result findList(SupplierItemRequestDto dto) {
try { try {
...@@ -226,7 +228,11 @@ public class SupplierItemServiceImpl implements SupplierItemService { ...@@ -226,7 +228,11 @@ public class SupplierItemServiceImpl implements SupplierItemService {
return Result.failed("扣减库存失败"); return Result.failed("扣减库存失败");
} }
/**
* 废弃
* @param dto
* @return
*/
@Override @Override
public Result findItemsOfCurrentDistributor(SupplierItemRequestDto dto) { public Result findItemsOfCurrentDistributor(SupplierItemRequestDto dto) {
try { try {
...@@ -266,10 +272,8 @@ public class SupplierItemServiceImpl implements SupplierItemService { ...@@ -266,10 +272,8 @@ public class SupplierItemServiceImpl implements SupplierItemService {
sellerId = distributorBind.getDistributorId(); sellerId = distributorBind.getDistributorId();
} else { } else {
//查询是否有最近一次浏览的分销商记录 //查询是否有最近一次浏览的分销商记录
UserRecentBrowse userRecentBrowse = userRecentBrowseDao.findByUserId(userId); List<UserRecentBrowse> userRecentBrowse = userRecentBrowseDao.findByUserId(userId);
if (userRecentBrowse != null && userRecentBrowse.getSharerId() != null) {
sellerId = userRecentBrowse.getSharerId();
}
} }
DistributorShareRecordRequestDto distributorShareRecordRequestDto = new DistributorShareRecordRequestDto(); DistributorShareRecordRequestDto distributorShareRecordRequestDto = new DistributorShareRecordRequestDto();
distributorShareRecordRequestDto.setDistributorId(sellerId); distributorShareRecordRequestDto.setDistributorId(sellerId);
...@@ -506,7 +510,7 @@ public class SupplierItemServiceImpl implements SupplierItemService { ...@@ -506,7 +510,7 @@ public class SupplierItemServiceImpl implements SupplierItemService {
collectionItemsRelationRequestDto.setUserId(dto.getUserId()); collectionItemsRelationRequestDto.setUserId(dto.getUserId());
collectionItemsRelationService.create(collectionItemsRelationRequestDto); collectionItemsRelationService.create(collectionItemsRelationRequestDto);
} }
return Result.success(); return Result.success(new HashMap(){{put("id", itemId);}});
} catch (Exception e) { } catch (Exception e) {
logger.error("上传藏品失败 error : {}", e); logger.error("上传藏品失败 error : {}", e);
} }
...@@ -637,4 +641,94 @@ public class SupplierItemServiceImpl implements SupplierItemService { ...@@ -637,4 +641,94 @@ public class SupplierItemServiceImpl implements SupplierItemService {
} }
return Result.failed(); return Result.failed();
} }
@Override
public Result homePage(SupplierItemRequestDto dto) {
try {
List<SupplierItemVo> supplierItemVos = new ArrayList<>();
//为了小程序过审,关闭列表展示,0关闭,1打开,展示一个默认
Switch sswitch = switchDao.find();
//当前用户
Long userId = dto.getUserId();
if (sswitch.getState() == 0) {
//开关关闭状态,检查是否有用户id,有的话检查是否有浏览记录
if (ObjectUtils.isEmpty(userId)) {
SupplierItem supplierItem = supplierItemDao.findById(3289012L);
SupplierItemVo supplierItemVo = new SupplierItemVo();
EntityMapper.copyAttribute(supplierItem, supplierItemVo);
supplierItemVo.setSalePrice(PriceUtil.convertPriceFenToYuan(100L));
supplierItemVo.setHomePageImage(MediaUtil.getHomePageImage(supplierItem.getImages(), supplierItem.getVideos()));
supplierItemVos.add(supplierItemVo);
PageSearchResult pageSearchResult = new PageSearchResult();
pageSearchResult.setTotal(1L);
pageSearchResult.setPageSize(20);
pageSearchResult.setPageIndex(1);
pageSearchResult.setIsHasNextPage(false);
pageSearchResult.setDataList(supplierItemVos);
return Result.success(pageSearchResult);
}
}
if (sswitch.getState() == 1) {
if (ObjectUtils.isEmpty(userId)) {
return Result.failed(ResultCode.UNLOGIN);
}
}
//用户默认展示逍遥分享的商品列表
long sellerId = 291997;
SupplierItemRequestDto searchDto = new SupplierItemRequestDto();
//查询用户的历史浏览记录
List<UserRecentBrowse> userRecentBrowseList = userRecentBrowseDao.findByUserId(userId);
List<Long> sharedUserIdList = userRecentBrowseList.stream().map(UserRecentBrowse::getSharedUserId).collect(Collectors.toList());
List<DistributorShareRecord> distributorShareRecordList = new ArrayList<>();
if (!CollectionUtils.isEmpty(sharedUserIdList)) {
searchDto.setCreatorIdList(sharedUserIdList);
DistributorShareRecordRequestDto distributorShareRecordRequestDto = new DistributorShareRecordRequestDto();
distributorShareRecordRequestDto.setDistributorIdList(sharedUserIdList);
distributorShareRecordRequestDto.setType(dto.getType());
distributorShareRecordList = distributorShareRecordDao.find(distributorShareRecordRequestDto);
List<Long> distributorShareItemIds = distributorShareRecordList.stream().map(DistributorShareRecord::getItemId).collect(Collectors.toList());
searchDto.setIds(distributorShareItemIds);
}
Map<Long, DistributorShareRecord> map = distributorShareRecordList.stream().collect(Collectors.toMap(DistributorShareRecord::getItemId, Function.identity(), (k1, k2) -> k1));
searchDto.setIsOnSale(true);
searchDto.setIsDeleted(false);
if (dto.getType() == DistributionEnum.DistributionTypeEnum.FIXED_PRICE.getCode()) {
searchDto.setTypeList(Arrays.asList(DistributionEnum.DistributionTypeEnum.FIXED_PRICE.getCode(), DistributionEnum.DistributionTypeEnum.COLLECT.getCode()));
} else {
searchDto.setTypeList(Arrays.asList(DistributionEnum.DistributionTypeEnum.AUCTION.getCode()));
}
searchDto.setCreatorIdList(sharedUserIdList);
searchDto.setStock(0);//库存大于0
searchDto.setPage(dto.getPage());
searchDto.setLimit(dto.getLimit());
List<SupplierItem> supplierItemList = supplierItemDao.findForHomePage(searchDto);
logger.info(">>>>>>> supplierItemList >>>>> : {}", JsonUtils.from(supplierItemList));
PageInfo<SupplierItem> pageInfo = new PageInfo(supplierItemList);
supplierItemList.forEach(supplierItem -> {
SupplierItemVo supplierItemVo = new SupplierItemVo();
EntityMapper.copyAttribute(supplierItem, supplierItemVo);
supplierItemVo.setHomePageImage(MediaUtil.getHomePageImage(supplierItem.getImages(), supplierItem.getVideos()));
logger.info("商品id:{}, 对应shareid : {}", supplierItem.getId(), map.get(supplierItem.getId()).getShareId());
supplierItemVo.setShareId(map.get(supplierItem.getId()).getShareId());
//竞拍商品需要展示当前价
if (supplierItem.getType() == DistributionEnum.DistributionTypeEnum.AUCTION.getCode()) {
AuctionRecord auctionRecord = auctionRecordDao.findLastedRecord(supplierItem.getId());
if (auctionRecord != null && auctionRecord.getPrice() != null) {
supplierItemVo.setCurrentPrice(PriceUtil.convertPriceFenToYuan(auctionRecord.getPrice()));
} else {
supplierItemVo.setCurrentPrice("0");
}
AuctionConfig auctionConfig = auctionConfigDao.findByItemId(supplierItem.getId());
supplierItemVo.setRealEndTime(auctionConfig.getRealEndTime());
}
supplierItemVos.add(supplierItemVo);
});
return Result.success(PageSearchResult.of(pageInfo, supplierItemVos));
} catch (Exception e) {
logger.error("查询最近订单所属分销商的商品列表,商品类型为:{}, error : {}", dto.getType(), e);
}
return Result.failed();
}
} }
...@@ -82,4 +82,11 @@ public interface SupplierItemService { ...@@ -82,4 +82,11 @@ public interface SupplierItemService {
*/ */
Result delete(SupplierItemRequestDto dto); Result delete(SupplierItemRequestDto dto);
/**
* 主页列表
* @param dto
* @return
*/
Result homePage(SupplierItemRequestDto dto);
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment