|
|
@@ -13,6 +13,7 @@ import com.cyksj.common.exception.BusinessRuntimeException;
|
|
|
import com.cyksj.common.util.Jsons;
|
|
|
import com.cyksj.common.util.StringUtil;
|
|
|
import com.cyksj.dto.Result;
|
|
|
+import com.cyksj.dto.UserSharedDto;
|
|
|
import com.cyksj.enums.GatewayResponse;
|
|
|
import com.cyksj.mapper.GoodsDonSkuMapper;
|
|
|
import com.cyksj.mapper.OrderDonMapper;
|
|
|
@@ -24,6 +25,7 @@ import com.cyksj.model.views.*;
|
|
|
import com.cyksj.redis.RedisService;
|
|
|
import com.cyksj.service.home.ClickRecordFrontService;
|
|
|
import com.cyksj.service.shop.YhShopFrontService;
|
|
|
+import com.cyksj.service.user.UserService;
|
|
|
import com.cyksj.web.util.StpUserUtil;
|
|
|
import com.ejlchina.searcher.BeanSearcher;
|
|
|
import com.ejlchina.searcher.SearchResult;
|
|
|
@@ -69,6 +71,8 @@ public class GoodsDonController {
|
|
|
|
|
|
private final YhShopFrontService yhShopFrontService;
|
|
|
|
|
|
+ private final UserService userService;
|
|
|
+
|
|
|
/**
|
|
|
* 获取平台商品分类
|
|
|
*/
|
|
|
@@ -326,16 +330,15 @@ public class GoodsDonController {
|
|
|
* 获取商品详情
|
|
|
*/
|
|
|
@GetMapping("/get/{id}")
|
|
|
- public Result<? extends Object> getDetail(@PathVariable Long id, String customId) {
|
|
|
+ public Result<? extends Object> getDetail(@PathVariable Long id, String customId, String dsCode) {
|
|
|
if (StrUtil.isNotBlank(customId) && id != 15) {
|
|
|
Result<YhShopGoodsFrontView> yhShopGoodsDetail = getGoodsDetailByYhsId(yhShopFrontService.getYhsIdByCustomId(customId), id);
|
|
|
return yhShopGoodsDetail;
|
|
|
}
|
|
|
String goodsDetailKey = RedisService.key.YH_HOME_PAGHE_CACHE.getEnvName() + "goods_detail:" + id;
|
|
|
Object o = redisService.get(goodsDetailKey);
|
|
|
- GoodsFrontListView views = null;
|
|
|
if (o == null) {
|
|
|
- views = beanSearcher.searchFirst(GoodsFrontListView.class, MapUtils.builder().field(GoodsFrontListView::getId, id)
|
|
|
+ GoodsFrontListView views = beanSearcher.searchFirst(GoodsFrontListView.class, MapUtils.builder().field(GoodsFrontListView::getId, id)
|
|
|
.build());
|
|
|
|
|
|
views.setSpecs(beanSearcher.searchFirst(GoodsDonSpecFrontView.class, MapUtils.builder().field(GoodsDonSpecFrontView::getGoodsId, views.getId()).build()));
|
|
|
@@ -349,10 +352,19 @@ public class GoodsDonController {
|
|
|
o = redisService.get(goodsDetailKey);
|
|
|
}
|
|
|
Long fUid = StpUserUtil.getUserIdAfterLogin();
|
|
|
- if (views == null) {
|
|
|
- views = Jsons.parseObject(o, GoodsFrontListView.class);
|
|
|
+ GoodsFrontListView views = Jsons.parseObject(o, GoodsFrontListView.class);
|
|
|
+ Long sharedId = null;
|
|
|
+ if (StrUtil.isNotBlank(dsCode)) {
|
|
|
+ UserSharedDto userSharedDto = userService.getUserShredDtoByDsCode(dsCode);
|
|
|
+ sharedId = userSharedDto.getSharedId();
|
|
|
}
|
|
|
- for (GoodsDonSkuFrontView sku : views.getSkuList()) {
|
|
|
+ final Long dsUserId = sharedId;
|
|
|
+ views.setSkuList(views.getSkuList().stream().filter(sku -> {
|
|
|
+ if (StrUtil.isNotBlank(sku.getUserOwns())) {
|
|
|
+ if (StrUtil.isEmpty(dsCode) || (dsUserId == null || !sku.getUserOwns().contains(dsUserId.toString()))) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
if (sku.getIsDp()) {
|
|
|
sku.setDpSkuViews(beanSearcher.searchAll(GoodsDiscountPlusPurchaseRelationFrontView.class, MapUtils.builder()
|
|
|
.field(GoodsDiscountPlusPurchaseRelationFrontView::getSkuId, sku.getId())
|
|
|
@@ -362,27 +374,28 @@ public class GoodsDonController {
|
|
|
if (fUid == null) {
|
|
|
sku.setSpecificPrice(null);
|
|
|
sku.setSpecificGoodsIds(null);
|
|
|
- continue;
|
|
|
- }
|
|
|
- //设置特定价格
|
|
|
- if (!isPaySpecificGoodsIds(sku.getSpecificGoodsIds(), fUid)) {
|
|
|
- sku.setSpecificGoodsIds(null);
|
|
|
- sku.setSpecificPrice(null);
|
|
|
- } else {
|
|
|
- BigDecimal specificPrice = views.getSpecificPrice();
|
|
|
-
|
|
|
- BigDecimal skuSpecificPrice = sku.getSpecificPrice();
|
|
|
- Long specificSkuId = sku.getId();
|
|
|
- if (specificPrice == null) {
|
|
|
- views.setSpecificPrice(skuSpecificPrice);
|
|
|
- views.setSpecificSkuId(specificSkuId);
|
|
|
- } else if (specificPrice.compareTo(skuSpecificPrice) > 0) {
|
|
|
- views.setSpecificPrice(skuSpecificPrice);
|
|
|
- views.setSpecificSkuId(specificSkuId);
|
|
|
+ }else {
|
|
|
+ //设置特定价格
|
|
|
+ if (!isPaySpecificGoodsIds(sku.getSpecificGoodsIds(), fUid)) {
|
|
|
+ sku.setSpecificGoodsIds(null);
|
|
|
+ sku.setSpecificPrice(null);
|
|
|
+ } else {
|
|
|
+ BigDecimal specificPrice = views.getSpecificPrice();
|
|
|
+
|
|
|
+ BigDecimal skuSpecificPrice = sku.getSpecificPrice();
|
|
|
+ Long specificSkuId = sku.getId();
|
|
|
+ if (specificPrice == null) {
|
|
|
+ views.setSpecificPrice(skuSpecificPrice);
|
|
|
+ views.setSpecificSkuId(specificSkuId);
|
|
|
+ } else if (specificPrice.compareTo(skuSpecificPrice) > 0) {
|
|
|
+ views.setSpecificPrice(skuSpecificPrice);
|
|
|
+ views.setSpecificSkuId(specificSkuId);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
+ return true;
|
|
|
+ }).collect(Collectors.toList()));
|
|
|
Integer sold = orderDonMapper.selectCount(Wrappers.lambdaQuery(OrderDon.class)
|
|
|
.eq(OrderDon::getGoodsId, views.getId()).notIn(OrderDon::getStatus, Constant.noOrderStatus));
|
|
|
views.setSold(sold + views.getSold());
|
|
|
@@ -482,7 +495,7 @@ public class GoodsDonController {
|
|
|
* 获取首页配置列表
|
|
|
*/
|
|
|
@GetMapping("/get/homeManage")
|
|
|
- public Result<Map<String, List<HomeManagementFrontView>>> getHomeManagementFrontPage(String customId) {
|
|
|
+ public Result<Map<String, List<HomeManagementFrontView>>> getHomeManagementFrontPage(String customId, String dsCode) {
|
|
|
String key = RedisService.key.YH_HOME_PAGHE_CACHE.getEnvName() + "homeManage";
|
|
|
Long yhsId = null;
|
|
|
if (StrUtil.isNotBlank(customId)) {
|
|
|
@@ -511,18 +524,36 @@ public class GoodsDonController {
|
|
|
redisService.setNx(key, map, 50 * 60l);
|
|
|
o = redisService.get(key);
|
|
|
}
|
|
|
+ Long sharedId = null;
|
|
|
+ if (StrUtil.isNotBlank(dsCode)) {
|
|
|
+ UserSharedDto userSharedDto = userService.getUserShredDtoByDsCode(dsCode);
|
|
|
+ sharedId = userSharedDto.getSharedId();
|
|
|
+ }
|
|
|
+ final Long dsUserId = sharedId;
|
|
|
Map<String, List<HomeManagementFrontView>> map = Jsons.parseObject(o, Map.class);
|
|
|
if (map.containsKey(HomeManagementConfig.Type.ex.name()) || map.containsKey(HomeManagementConfig.Type.vg.name())) {
|
|
|
try {
|
|
|
//设置特定价格
|
|
|
List<HomeManagementFrontView> exList = Jsons.parseList(Jsons.toJson(map.get(HomeManagementConfig.Type.ex.name())), HomeManagementFrontView.class);
|
|
|
if (CollUtil.isNotEmpty(exList)) {
|
|
|
+ exList = exList.stream().filter(data -> {
|
|
|
+ if (data.getIsOwns() && goodsDonSkuMapper.checkUserOwnsSku(data.getGoodsId(), dsUserId) == null) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
setHomeManageSpecific(exList, fUid);
|
|
|
map.put(HomeManagementConfig.Type.ex.name(), exList);
|
|
|
}
|
|
|
//设置特定价格
|
|
|
List<HomeManagementFrontView> vgList = Jsons.parseList(Jsons.toJson(map.get(HomeManagementConfig.Type.vg.name())), HomeManagementFrontView.class);
|
|
|
if (CollUtil.isNotEmpty(vgList)) {
|
|
|
+ vgList = vgList.stream().filter(data -> {
|
|
|
+ if (data.getIsOwns() && goodsDonSkuMapper.checkUserOwnsSku(data.getGoodsId(), dsUserId) == null) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
setHomeManageSpecific(vgList, fUid);
|
|
|
map.put(HomeManagementConfig.Type.vg.name(), vgList);
|
|
|
}
|
|
|
@@ -843,7 +874,7 @@ public class GoodsDonController {
|
|
|
* 根据分类获取对应平台
|
|
|
*/
|
|
|
@GetMapping("/get/categoryGoods")
|
|
|
- public Result<? extends Object> getGoodsByCategory(Long cgy, String customId) {
|
|
|
+ public Result<? extends Object> getGoodsByCategory(Long cgy, String customId, String dsCode) {
|
|
|
if (StrUtil.isNotBlank(customId)) {
|
|
|
Result<List<YhShopGoodsFrontCategoryView>> shopGoods = getShopCategoryGoods(yhShopFrontService.getYhsIdByCustomId(customId), cgy);
|
|
|
return shopGoods;
|
|
|
@@ -866,14 +897,24 @@ public class GoodsDonController {
|
|
|
}
|
|
|
List<GoodsFrontListCategoryView> goodsFrontListViews = Jsons.parseList(o, GoodsFrontListCategoryView.class);
|
|
|
DateTime now = DateTime.now();
|
|
|
- goodsFrontListViews.forEach(data -> {
|
|
|
+ Long sharedId = null;
|
|
|
+ if (StrUtil.isNotBlank(dsCode)) {
|
|
|
+ UserSharedDto userSharedDto = userService.getUserShredDtoByDsCode(dsCode);
|
|
|
+ sharedId = userSharedDto.getSharedId();
|
|
|
+ }
|
|
|
+ final Long dsUserId = sharedId;
|
|
|
+ goodsFrontListViews = goodsFrontListViews.stream().filter(data -> {
|
|
|
+ if (data.getIsOwns() && goodsDonSkuMapper.checkUserOwnsSku(data.getId(), dsUserId) == null) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
Integer sold = orderDonMapper.selectCount(Wrappers.lambdaQuery(OrderDon.class)
|
|
|
.eq(OrderDon::getGoodsId, data.getId()).notIn(OrderDon::getStatus, Constant.noOrderStatus));
|
|
|
data.setSold(sold + data.getSold());
|
|
|
data.setNotifyMsg(getPayMsgTime(data.getId(), now, 1, null));
|
|
|
//设置特定价格
|
|
|
setGcSpecificPrice(data, fUid);
|
|
|
- });
|
|
|
+ return true;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(goodsFrontListViews);
|
|
|
}
|
|
|
|