Commit eb27168b authored by shiyu's avatar shiyu

缺失字段补充

parent 25944b8d
...@@ -40,6 +40,11 @@ public interface CommConsts { ...@@ -40,6 +40,11 @@ public interface CommConsts {
public static final Long SYSTEM_ACCOUNT = 8888888888L; public static final Long SYSTEM_ACCOUNT = 8888888888L;
/**
* 系统默认用户头像URL
*/
public static final String DEFAULT_AVATAR_URL = "https://cdn.wanwudezhi.com/mall-portal/image/4337400862";
} }
...@@ -220,4 +220,14 @@ public class SupplierItemVo implements Entity { ...@@ -220,4 +220,14 @@ public class SupplierItemVo implements Entity {
* 收藏人头像 * 收藏人头像
*/ */
private List<String> collectorsAvatar; private List<String> collectorsAvatar;
/**
* 当前用户是否已收藏
*/
private Boolean isCollected;
/**
* 当前用户是否已分享过
*/
private Boolean isShared;
} }
...@@ -68,4 +68,5 @@ public interface DistributorShareRecordDao { ...@@ -68,4 +68,5 @@ public interface DistributorShareRecordDao {
*/ */
DistributorShareRecord findItemShareRecordByDistributorId(long distributorId, long itemId); DistributorShareRecord findItemShareRecordByDistributorId(long distributorId, long itemId);
} }
...@@ -37,6 +37,7 @@ public class DistributorShareRecordDaoImpl implements DistributorShareRecordDao ...@@ -37,6 +37,7 @@ public class DistributorShareRecordDaoImpl implements DistributorShareRecordDao
DistributorShareRecordExample.Criteria criteria = example.createCriteria(); DistributorShareRecordExample.Criteria criteria = example.createCriteria();
JdbcHelper.ifPresent(dto.getDistributorIdList(), criteria::andDistributorIdIn); JdbcHelper.ifPresent(dto.getDistributorIdList(), criteria::andDistributorIdIn);
JdbcHelper.ifPresent(dto.getItemIdList(), criteria::andItemIdIn); JdbcHelper.ifPresent(dto.getItemIdList(), criteria::andItemIdIn);
JdbcHelper.ifPresent(dto.getType(), criteria::andTypeEqualTo);
criteria.andEnabledEqualTo(true); criteria.andEnabledEqualTo(true);
return distributorShareRecordMapper.selectByExample(example); return distributorShareRecordMapper.selectByExample(example);
} }
......
...@@ -86,12 +86,17 @@ public class SupplierItemDaoImpl implements SupplierItemDao { ...@@ -86,12 +86,17 @@ public class SupplierItemDaoImpl implements SupplierItemDao {
public List<SupplierItem> findForHomePage(SupplierItemRequestDto dto) { public List<SupplierItem> findForHomePage(SupplierItemRequestDto dto) {
SupplierItemExample supplierItemExample = new SupplierItemExample(); SupplierItemExample supplierItemExample = new SupplierItemExample();
SupplierItemExample.Criteria criteria = supplierItemExample.createCriteria(); SupplierItemExample.Criteria criteria = supplierItemExample.createCriteria();
JdbcHelper.ifPresent(dto.getId(), criteria::andIdEqualTo); criteria.andCreatorIdIn(dto.getCreatorIdList());
JdbcHelper.ifPresent(dto.getIds(), criteria::andIdIn); criteria.andTypeIn(dto.getTypeList());
JdbcHelper.ifPresent(dto.getType(), criteria::andTypeEqualTo); criteria.andStockGreaterThan(0);
JdbcHelper.ifPresent(dto.getStock(), criteria::andStockGreaterThan); criteria.andIsDeletedEqualTo(false);
JdbcHelper.ifPresent(dto.getIsOnSale(), criteria::andIsOnSaleEqualTo); criteria.andIsOnSaleEqualTo(true);
JdbcHelper.ifPresent(dto.getIsDeleted(), criteria::andIsDeletedEqualTo); SupplierItemExample.Criteria orCriteria = supplierItemExample.or();
orCriteria.andIdIn(dto.getIds());
orCriteria.andTypeIn(dto.getTypeList());
orCriteria.andStockGreaterThan(0);
orCriteria.andIsDeletedEqualTo(false);
orCriteria.andIsOnSaleEqualTo(true);
supplierItemExample.setOrderByClause(" update_time desc"); supplierItemExample.setOrderByClause(" update_time desc");
PageHelper.startPage(dto.getPage(), dto.getLimit()); PageHelper.startPage(dto.getPage(), dto.getLimit());
return supplierItemMapper.selectByExampleWithBLOBs(supplierItemExample); return supplierItemMapper.selectByExampleWithBLOBs(supplierItemExample);
......
...@@ -38,6 +38,10 @@ public class OfficialAccountCallbackController { ...@@ -38,6 +38,10 @@ public class OfficialAccountCallbackController {
private final static String UNSUBSCRIBE_EVENT = "unsubscribe"; private final static String UNSUBSCRIBE_EVENT = "unsubscribe";
//一次性订阅消息
private final static String SUBSCRIBE_MSG_POPUP_EVENT = "subscribe_msg_popup_event";
@Value("${dts.wx.officialaccount-token}") @Value("${dts.wx.officialaccount-token}")
private String OFFICIALACCOUNTTOKEN; private String OFFICIALACCOUNTTOKEN;
...@@ -122,7 +126,12 @@ public class OfficialAccountCallbackController { ...@@ -122,7 +126,12 @@ public class OfficialAccountCallbackController {
officialAccountSubscribeRecord.setPlatformType(OfficalAccountEnum.PlatformTypeEnum.WECHAT.getCode()); officialAccountSubscribeRecord.setPlatformType(OfficalAccountEnum.PlatformTypeEnum.WECHAT.getCode());
officialAccountSubscribeRecordService.insert(officialAccountSubscribeRecord); officialAccountSubscribeRecordService.insert(officialAccountSubscribeRecord);
} }
logger.info("=============== 更新订阅记录成功 =============="); logger.info("=============== 更新订阅公众号记录成功 ==============");
} else if (SUBSCRIBE_MSG_POPUP_EVENT.equals(event)) {
//一次性订阅消息
} }
} catch (Exception e) { } catch (Exception e) {
logger.error("微信公众号通知回调接口 error : {}", e); logger.error("微信公众号通知回调接口 error : {}", e);
......
package com.wwdz.ch.wx.impl.distribution; package com.wwdz.ch.wx.impl.distribution;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.wwdz.ch.core.consts.CommConsts;
import com.wwdz.ch.core.consts.DistributionEnum; import com.wwdz.ch.core.consts.DistributionEnum;
import com.wwdz.ch.core.consts.ResultCode; import com.wwdz.ch.core.consts.ResultCode;
import com.wwdz.ch.core.type.PageSearchResult; import com.wwdz.ch.core.type.PageSearchResult;
...@@ -8,6 +9,7 @@ import com.wwdz.ch.core.type.Result; ...@@ -8,6 +9,7 @@ import com.wwdz.ch.core.type.Result;
import com.wwdz.ch.core.util.CacheUtil; import com.wwdz.ch.core.util.CacheUtil;
import com.wwdz.ch.core.util.MediaUtil; import com.wwdz.ch.core.util.MediaUtil;
import com.wwdz.ch.core.util.PriceUtil; import com.wwdz.ch.core.util.PriceUtil;
import com.wwdz.ch.core.util.StringUtil;
import com.wwdz.ch.db.dao.SwitchDao; import com.wwdz.ch.db.dao.SwitchDao;
import com.wwdz.ch.db.dao.distribution.*; import com.wwdz.ch.db.dao.distribution.*;
import com.wwdz.ch.db.domain.Switch; import com.wwdz.ch.db.domain.Switch;
...@@ -173,6 +175,7 @@ public class SupplierItemServiceImpl implements SupplierItemService { ...@@ -173,6 +175,7 @@ public class SupplierItemServiceImpl implements SupplierItemService {
newRecord.setUserId(dto.getUserId()); newRecord.setUserId(dto.getUserId());
newRecord.setCreateTime(new Date()); newRecord.setCreateTime(new Date());
newRecord.setUpdateTime(new Date()); newRecord.setUpdateTime(new Date());
newRecord.setType(DistributionEnum.UserBrowseTypeEnum.PLATFORM_ITEM.getCode());
userRecentBrowseDao.insert(newRecord); userRecentBrowseDao.insert(newRecord);
} }
} else { } else {
...@@ -182,6 +185,13 @@ public class SupplierItemServiceImpl implements SupplierItemService { ...@@ -182,6 +185,13 @@ public class SupplierItemServiceImpl implements SupplierItemService {
} else { } else {
supplierItemVo.setShopBought(false); supplierItemVo.setShopBought(false);
} }
//判断商家是否已经分享过
DistributorShareRecord shareRecord = distributorShareRecordDao.findItemShareRecordByDistributorId(dto.getUserId(), itemId);
if (shareRecord != null && StringUtils.hasLength(shareRecord.getShareId())) {
supplierItemVo.setIsShared(true);
} else {
supplierItemVo.setIsShared(false);
}
} }
SupplierItem supplierItem = supplierItemDao.findById(itemId); SupplierItem supplierItem = supplierItemDao.findById(itemId);
EntityMapper.copyAttribute(supplierItem, supplierItemVo); EntityMapper.copyAttribute(supplierItem, supplierItemVo);
...@@ -573,12 +583,20 @@ public class SupplierItemServiceImpl implements SupplierItemService { ...@@ -573,12 +583,20 @@ public class SupplierItemServiceImpl implements SupplierItemService {
itemId = collectionShareRecord.getShareTargetId(); itemId = collectionShareRecord.getShareTargetId();
} }
supplierItemVo.setIsCollected(true);
SupplierItem supplierItem = supplierItemDao.findById(itemId); SupplierItem supplierItem = supplierItemDao.findById(itemId);
if (supplierItem.getCreatorId().longValue() != userId) { if (supplierItem.getCreatorId().longValue() != userId) {
supplierItemVo.setIsMine(false); supplierItemVo.setIsMine(false);
boolean isCollected = itemCollectedRecordDao.isExisted(itemId, userId);
if (isCollected) {
supplierItemVo.setIsCollected(true);
} else {
supplierItemVo.setIsCollected(false);
}
if (supplierItem.getIsDeleted()) { if (supplierItem.getIsDeleted()) {
//判断是否有相关收藏记录,有则删除 //判断是否有相关收藏记录,有则删除
if (itemCollectedRecordDao.isExisted(itemId, userId)) { if (isCollected) {
itemCollectedRecordDao.cancel(itemId, userId); itemCollectedRecordDao.cancel(itemId, userId);
} }
return Result.failed("该藏品已删除"); return Result.failed("该藏品已删除");
...@@ -609,7 +627,8 @@ public class SupplierItemServiceImpl implements SupplierItemService { ...@@ -609,7 +627,8 @@ public class SupplierItemServiceImpl implements SupplierItemService {
List<Long> collectorIds = itemCollectedRecords.stream().map(ItemCollectedRecord::getCollectorsId).collect(Collectors.toList()); List<Long> collectorIds = itemCollectedRecords.stream().map(ItemCollectedRecord::getCollectorsId).collect(Collectors.toList());
List<String> avatarList = new ArrayList<>(); List<String> avatarList = new ArrayList<>();
for (Long collectorId : collectorIds) { for (Long collectorId : collectorIds) {
avatarList.add(cacheUtil.getAppletUserById(collectorId).getAvatar()); String avatar = cacheUtil.getAppletUserById(collectorId).getAvatar();
avatarList.add(StringUtils.isEmpty(avatar) ? CommConsts.DEFAULT_AVATAR_URL : avatar);
} }
supplierItemVo.setCollectorsAvatar(avatarList); supplierItemVo.setCollectorsAvatar(avatarList);
} }
...@@ -618,7 +637,8 @@ public class SupplierItemServiceImpl implements SupplierItemService { ...@@ -618,7 +637,8 @@ public class SupplierItemServiceImpl implements SupplierItemService {
supplierItemVo.setDistributionPrice(PriceUtil.convertPriceFenToYuan(supplierItem.getDistributionPrice())); supplierItemVo.setDistributionPrice(PriceUtil.convertPriceFenToYuan(supplierItem.getDistributionPrice()));
supplierItemVo.setHomePageImage(MediaUtil.getHomePageImage(supplierItem.getImages(), supplierItem.getVideos())); supplierItemVo.setHomePageImage(MediaUtil.getHomePageImage(supplierItem.getImages(), supplierItem.getVideos()));
supplierItemVo.setCreatorName(cacheUtil.getAppletUserNameById(supplierItem.getCreatorId())); supplierItemVo.setCreatorName(cacheUtil.getAppletUserNameById(supplierItem.getCreatorId()));
supplierItemVo.setCreatorAvatar(cacheUtil.getAppletUserById(supplierItem.getCreatorId()).getAvatar()); String avatar = cacheUtil.getAppletUserById(supplierItem.getCreatorId()).getAvatar();
supplierItemVo.setCreatorAvatar(StringUtils.isEmpty(avatar) ? CommConsts.DEFAULT_AVATAR_URL : avatar);
//查询藏品被收藏的次数 //查询藏品被收藏的次数
long countNum = itemCollectedRecordDao.countByItemId(dto.getId()); long countNum = itemCollectedRecordDao.countByItemId(dto.getId());
supplierItemVo.setCollectedNum((int) countNum); supplierItemVo.setCollectedNum((int) countNum);
...@@ -644,7 +664,7 @@ public class SupplierItemServiceImpl implements SupplierItemService { ...@@ -644,7 +664,7 @@ public class SupplierItemServiceImpl implements SupplierItemService {
@Override @Override
public Result homePage(SupplierItemRequestDto dto) { public Result findHomePage(SupplierItemRequestDto dto) {
try { try {
List<SupplierItemVo> supplierItemVos = new ArrayList<>(); List<SupplierItemVo> supplierItemVos = new ArrayList<>();
//为了小程序过审,关闭列表展示,0关闭,1打开,展示一个默认 //为了小程序过审,关闭列表展示,0关闭,1打开,展示一个默认
...@@ -679,19 +699,27 @@ public class SupplierItemServiceImpl implements SupplierItemService { ...@@ -679,19 +699,27 @@ public class SupplierItemServiceImpl implements SupplierItemService {
SupplierItemRequestDto searchDto = new SupplierItemRequestDto(); SupplierItemRequestDto searchDto = new SupplierItemRequestDto();
//查询用户的历史浏览记录 //查询用户的历史浏览记录
List<UserRecentBrowse> userRecentBrowseList = userRecentBrowseDao.findByUserId(userId); List<UserRecentBrowse> userRecentBrowseList = userRecentBrowseDao.findByUserId(userId);
List<Long> sharedUserIdList = userRecentBrowseList.stream().map(UserRecentBrowse::getSharedUserId).collect(Collectors.toList()); //浏览记录是平台商品的
List<DistributorShareRecord> distributorShareRecordList = new ArrayList<>(); List<Long> sharedUserIdList = userRecentBrowseList.stream().filter(a -> a.getType() == DistributionEnum.UserBrowseTypeEnum.PLATFORM_ITEM.getCode()).map(UserRecentBrowse::getSharedUserId).collect(Collectors.toList());
if (!CollectionUtils.isEmpty(sharedUserIdList)) { if (CollectionUtils.isEmpty(sharedUserIdList)) {
searchDto.setCreatorIdList(sharedUserIdList); sharedUserIdList.add(sellerId);
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.setCreatorIdList(sharedUserIdList);
DistributorShareRecordRequestDto distributorShareRecordRequestDto = new DistributorShareRecordRequestDto();
distributorShareRecordRequestDto.setDistributorIdList(sharedUserIdList);
distributorShareRecordRequestDto.setType(dto.getType());
List<DistributorShareRecord> distributorShareRecordList = distributorShareRecordDao.find(distributorShareRecordRequestDto);
//平台商品被分享出去对应的分销商的所有分享商品
List<Long> distributorShareItemIds = distributorShareRecordList.stream().filter(StringUtil.distinctByKey(DistributorShareRecord::getItemId)).map(DistributorShareRecord::getItemId).collect(Collectors.toList());
//浏览记录是用户上传的
List<Long> uploadUserIdList = userRecentBrowseList.stream().filter(a -> a.getType() == DistributionEnum.UserBrowseTypeEnum.USER_ITEM.getCode()).map(UserRecentBrowse::getSharedUserId).collect(Collectors.toList());
if (CollectionUtils.isEmpty(uploadUserIdList)) {
uploadUserIdList.add(sellerId);
}
searchDto.setIds(distributorShareItemIds);
Map<Long, DistributorShareRecord> map = distributorShareRecordList.stream().collect(Collectors.toMap(DistributorShareRecord::getItemId, Function.identity(), (k1, k2) -> k1));
searchDto.setIsOnSale(true); searchDto.setIsOnSale(true);
searchDto.setIsDeleted(false); searchDto.setIsDeleted(false);
if (dto.getType() == DistributionEnum.DistributionTypeEnum.FIXED_PRICE.getCode()) { if (dto.getType() == DistributionEnum.DistributionTypeEnum.FIXED_PRICE.getCode()) {
...@@ -699,19 +727,18 @@ public class SupplierItemServiceImpl implements SupplierItemService { ...@@ -699,19 +727,18 @@ public class SupplierItemServiceImpl implements SupplierItemService {
} else { } else {
searchDto.setTypeList(Arrays.asList(DistributionEnum.DistributionTypeEnum.AUCTION.getCode())); searchDto.setTypeList(Arrays.asList(DistributionEnum.DistributionTypeEnum.AUCTION.getCode()));
} }
searchDto.setCreatorIdList(sharedUserIdList); searchDto.setCreatorIdList(uploadUserIdList);
searchDto.setStock(0);//库存大于0 searchDto.setStock(0);//库存大于0
searchDto.setPage(dto.getPage()); searchDto.setPage(dto.getPage());
searchDto.setLimit(dto.getLimit()); searchDto.setLimit(dto.getLimit());
List<SupplierItem> supplierItemList = supplierItemDao.findForHomePage(searchDto); List<SupplierItem> supplierItemList = supplierItemDao.findForHomePage(searchDto);
logger.info(">>>>>>> supplierItemList >>>>> : {}", JsonUtils.from(supplierItemList));
PageInfo<SupplierItem> pageInfo = new PageInfo(supplierItemList); PageInfo<SupplierItem> pageInfo = new PageInfo(supplierItemList);
supplierItemList.forEach(supplierItem -> { supplierItemList.forEach(supplierItem -> {
SupplierItemVo supplierItemVo = new SupplierItemVo(); SupplierItemVo supplierItemVo = new SupplierItemVo();
EntityMapper.copyAttribute(supplierItem, supplierItemVo); EntityMapper.copyAttribute(supplierItem, supplierItemVo);
supplierItemVo.setItemId(supplierItem.getId());
supplierItemVo.setHomePageImage(MediaUtil.getHomePageImage(supplierItem.getImages(), supplierItem.getVideos())); 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())== null?"":map.get(supplierItem.getId()).getShareId());
supplierItemVo.setShareId(map.get(supplierItem.getId()).getShareId());
//竞拍商品需要展示当前价 //竞拍商品需要展示当前价
if (supplierItem.getType() == DistributionEnum.DistributionTypeEnum.AUCTION.getCode()) { if (supplierItem.getType() == DistributionEnum.DistributionTypeEnum.AUCTION.getCode()) {
AuctionRecord auctionRecord = auctionRecordDao.findLastedRecord(supplierItem.getId()); AuctionRecord auctionRecord = auctionRecordDao.findLastedRecord(supplierItem.getId());
...@@ -727,7 +754,7 @@ public class SupplierItemServiceImpl implements SupplierItemService { ...@@ -727,7 +754,7 @@ public class SupplierItemServiceImpl implements SupplierItemService {
}); });
return Result.success(PageSearchResult.of(pageInfo, supplierItemVos)); return Result.success(PageSearchResult.of(pageInfo, supplierItemVos));
} catch (Exception e) { } catch (Exception e) {
logger.error("查询最近订单所属分销商的商品列表,商品类型为:{}, error : {}", dto.getType(), e); logger.error("查询主页商品列表,商品类型为:{}, error : {}", dto.getType(), e);
} }
return Result.failed(); return Result.failed();
} }
......
...@@ -87,6 +87,6 @@ public interface SupplierItemService { ...@@ -87,6 +87,6 @@ public interface SupplierItemService {
* @param dto * @param dto
* @return * @return
*/ */
Result homePage(SupplierItemRequestDto dto); Result findHomePage(SupplierItemRequestDto dto);
} }
...@@ -131,4 +131,14 @@ public class SupplierItemController { ...@@ -131,4 +131,14 @@ public class SupplierItemController {
return supplierItemService.delete(dto); return supplierItemService.delete(dto);
} }
@ApiOperation(value = "查询主页列表")
@PostMapping("/findHomePage")
public Result findHomePage(@RequestBody SupplierItemRequestDto dto) {
logger.info("删除用户查询主页列表藏品,请求参数:{}", JSON.toJSONString(dto));
if (dto.getId() == null) {
return Result.failed(ResultCode.PARAM_ERROR);
}
return supplierItemService.findHomePage(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