|
|
@@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.etotem.cfc.common.Result;
|
|
|
+import com.etotem.cfc.dto.GiftConfigVO;
|
|
|
+import com.etotem.cfc.dto.MembershipLevelDTO;
|
|
|
import com.etotem.cfc.dto.ProductDTO;
|
|
|
import com.etotem.cfc.dto.ProductListQueryDTO;
|
|
|
import com.etotem.cfc.entity.AssessmentProduct;
|
|
|
@@ -45,6 +47,9 @@ public class ProductService {
|
|
|
@Resource
|
|
|
private ProductGiftRuleService productGiftRuleService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private ProductGiftService productGiftService;
|
|
|
+
|
|
|
@Resource
|
|
|
private AssessmentProductService assessmentProductService;
|
|
|
|
|
|
@@ -128,7 +133,7 @@ wrapper.in(Product::getId, productIds)
|
|
|
return Result.success(data);
|
|
|
}
|
|
|
|
|
|
- public Result<ProductDTO> detail(Long id) {
|
|
|
+ public Result<ProductDTO> detail(Long id, Long userId) {
|
|
|
Product product = productMapper.selectById(id);
|
|
|
if (product == null) {
|
|
|
return Result.error("商品不存在");
|
|
|
@@ -165,6 +170,25 @@ wrapper.in(Product::getId, productIds)
|
|
|
dto.setGiftLevelCode(giftRule.getLevelCode());
|
|
|
dto.setGiftLevelName(productGiftRuleService.getLevelName(giftRule.getLevelCode()));
|
|
|
}
|
|
|
+ // 可选赠品配置(当前用户等级)
|
|
|
+ if (userId != null) {
|
|
|
+ try {
|
|
|
+ User buyer = userMapper.selectById(userId);
|
|
|
+ if (buyer != null && buyer.getFamilyId() != null) {
|
|
|
+ MembershipLevelDTO currentLevel = membershipService.getCurrentLevel(buyer.getFamilyId());
|
|
|
+ String userLevel = currentLevel != null ? currentLevel.getLevelCode() : null;
|
|
|
+ if (userLevel != null && !"FREE".equals(userLevel)) {
|
|
|
+ List<GiftConfigVO> activeConfigs = productGiftService
|
|
|
+ .getActiveConfigsByProductAndLevel(id, userLevel);
|
|
|
+ if (!activeConfigs.isEmpty()) {
|
|
|
+ dto.setGiftConfigs(activeConfigs);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ // 赠品配置加载失败不影响商品详情
|
|
|
+ }
|
|
|
+ }
|
|
|
// 配送与履约配置(按 deliveryMethod 附带自取地点/服务者/线上时间段)
|
|
|
Map<String, Object> deliveryConfig = new HashMap<>();
|
|
|
productDeliveryConfigService.enrichProductDetail(id, product.getDeliveryMethod(), deliveryConfig);
|